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.util.HashUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.CacheModel;
023    
024    import com.liferay.portlet.trash.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                    groupId = objectInput.readLong();
143                    companyId = objectInput.readLong();
144                    userId = objectInput.readLong();
145                    userName = objectInput.readUTF();
146                    createDate = objectInput.readLong();
147                    classNameId = objectInput.readLong();
148                    classPK = objectInput.readLong();
149                    systemEventSetKey = objectInput.readLong();
150                    typeSettings = objectInput.readUTF();
151                    status = objectInput.readInt();
152            }
153    
154            @Override
155            public void writeExternal(ObjectOutput objectOutput)
156                    throws IOException {
157                    objectOutput.writeLong(entryId);
158                    objectOutput.writeLong(groupId);
159                    objectOutput.writeLong(companyId);
160                    objectOutput.writeLong(userId);
161    
162                    if (userName == null) {
163                            objectOutput.writeUTF(StringPool.BLANK);
164                    }
165                    else {
166                            objectOutput.writeUTF(userName);
167                    }
168    
169                    objectOutput.writeLong(createDate);
170                    objectOutput.writeLong(classNameId);
171                    objectOutput.writeLong(classPK);
172                    objectOutput.writeLong(systemEventSetKey);
173    
174                    if (typeSettings == null) {
175                            objectOutput.writeUTF(StringPool.BLANK);
176                    }
177                    else {
178                            objectOutput.writeUTF(typeSettings);
179                    }
180    
181                    objectOutput.writeInt(status);
182            }
183    
184            public long entryId;
185            public long groupId;
186            public long companyId;
187            public long userId;
188            public String userName;
189            public long createDate;
190            public long classNameId;
191            public long classPK;
192            public long systemEventSetKey;
193            public String typeSettings;
194            public int status;
195    }