001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.trash.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.model.CacheModel;
020    import com.liferay.portal.kernel.util.HashUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    import com.liferay.portal.kernel.util.StringPool;
023    
024    import com.liferay.trash.kernel.model.TrashEntry;
025    
026    import java.io.Externalizable;
027    import java.io.IOException;
028    import java.io.ObjectInput;
029    import java.io.ObjectOutput;
030    
031    import java.util.Date;
032    
033    /**
034     * The cache model class for representing TrashEntry in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see TrashEntry
038     * @generated
039     */
040    @ProviderType
041    public class TrashEntryCacheModel implements CacheModel<TrashEntry>,
042            Externalizable {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof TrashEntryCacheModel)) {
050                            return false;
051                    }
052    
053                    TrashEntryCacheModel trashEntryCacheModel = (TrashEntryCacheModel)obj;
054    
055                    if (entryId == trashEntryCacheModel.entryId) {
056                            return true;
057                    }
058    
059                    return false;
060            }
061    
062            @Override
063            public int hashCode() {
064                    return HashUtil.hash(0, entryId);
065            }
066    
067            @Override
068            public String toString() {
069                    StringBundler sb = new StringBundler(23);
070    
071                    sb.append("{entryId=");
072                    sb.append(entryId);
073                    sb.append(", groupId=");
074                    sb.append(groupId);
075                    sb.append(", companyId=");
076                    sb.append(companyId);
077                    sb.append(", userId=");
078                    sb.append(userId);
079                    sb.append(", userName=");
080                    sb.append(userName);
081                    sb.append(", createDate=");
082                    sb.append(createDate);
083                    sb.append(", classNameId=");
084                    sb.append(classNameId);
085                    sb.append(", classPK=");
086                    sb.append(classPK);
087                    sb.append(", systemEventSetKey=");
088                    sb.append(systemEventSetKey);
089                    sb.append(", typeSettings=");
090                    sb.append(typeSettings);
091                    sb.append(", status=");
092                    sb.append(status);
093                    sb.append("}");
094    
095                    return sb.toString();
096            }
097    
098            @Override
099            public TrashEntry toEntityModel() {
100                    TrashEntryImpl trashEntryImpl = new TrashEntryImpl();
101    
102                    trashEntryImpl.setEntryId(entryId);
103                    trashEntryImpl.setGroupId(groupId);
104                    trashEntryImpl.setCompanyId(companyId);
105                    trashEntryImpl.setUserId(userId);
106    
107                    if (userName == null) {
108                            trashEntryImpl.setUserName(StringPool.BLANK);
109                    }
110                    else {
111                            trashEntryImpl.setUserName(userName);
112                    }
113    
114                    if (createDate == Long.MIN_VALUE) {
115                            trashEntryImpl.setCreateDate(null);
116                    }
117                    else {
118                            trashEntryImpl.setCreateDate(new Date(createDate));
119                    }
120    
121                    trashEntryImpl.setClassNameId(classNameId);
122                    trashEntryImpl.setClassPK(classPK);
123                    trashEntryImpl.setSystemEventSetKey(systemEventSetKey);
124    
125                    if (typeSettings == null) {
126                            trashEntryImpl.setTypeSettings(StringPool.BLANK);
127                    }
128                    else {
129                            trashEntryImpl.setTypeSettings(typeSettings);
130                    }
131    
132                    trashEntryImpl.setStatus(status);
133    
134                    trashEntryImpl.resetOriginalValues();
135    
136                    return trashEntryImpl;
137            }
138    
139            @Override
140            public void readExternal(ObjectInput objectInput) throws IOException {
141                    entryId = objectInput.readLong();
142    
143                    groupId = objectInput.readLong();
144    
145                    companyId = objectInput.readLong();
146    
147                    userId = objectInput.readLong();
148                    userName = objectInput.readUTF();
149                    createDate = objectInput.readLong();
150    
151                    classNameId = objectInput.readLong();
152    
153                    classPK = objectInput.readLong();
154    
155                    systemEventSetKey = objectInput.readLong();
156                    typeSettings = objectInput.readUTF();
157    
158                    status = objectInput.readInt();
159            }
160    
161            @Override
162            public void writeExternal(ObjectOutput objectOutput)
163                    throws IOException {
164                    objectOutput.writeLong(entryId);
165    
166                    objectOutput.writeLong(groupId);
167    
168                    objectOutput.writeLong(companyId);
169    
170                    objectOutput.writeLong(userId);
171    
172                    if (userName == null) {
173                            objectOutput.writeUTF(StringPool.BLANK);
174                    }
175                    else {
176                            objectOutput.writeUTF(userName);
177                    }
178    
179                    objectOutput.writeLong(createDate);
180    
181                    objectOutput.writeLong(classNameId);
182    
183                    objectOutput.writeLong(classPK);
184    
185                    objectOutput.writeLong(systemEventSetKey);
186    
187                    if (typeSettings == null) {
188                            objectOutput.writeUTF(StringPool.BLANK);
189                    }
190                    else {
191                            objectOutput.writeUTF(typeSettings);
192                    }
193    
194                    objectOutput.writeInt(status);
195            }
196    
197            public long entryId;
198            public long groupId;
199            public long companyId;
200            public long userId;
201            public String userName;
202            public long createDate;
203            public long classNameId;
204            public long classPK;
205            public long systemEventSetKey;
206            public String typeSettings;
207            public int status;
208    }