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.journal.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.journal.model.JournalFolder;
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 JournalFolder in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see JournalFolder
038     * @generated
039     */
040    @ProviderType
041    public class JournalFolderCacheModel implements CacheModel<JournalFolder>,
042            Externalizable {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof JournalFolderCacheModel)) {
050                            return false;
051                    }
052    
053                    JournalFolderCacheModel journalFolderCacheModel = (JournalFolderCacheModel)obj;
054    
055                    if (folderId == journalFolderCacheModel.folderId) {
056                            return true;
057                    }
058    
059                    return false;
060            }
061    
062            @Override
063            public int hashCode() {
064                    return HashUtil.hash(0, folderId);
065            }
066    
067            @Override
068            public String toString() {
069                    StringBundler sb = new StringBundler(35);
070    
071                    sb.append("{uuid=");
072                    sb.append(uuid);
073                    sb.append(", folderId=");
074                    sb.append(folderId);
075                    sb.append(", groupId=");
076                    sb.append(groupId);
077                    sb.append(", companyId=");
078                    sb.append(companyId);
079                    sb.append(", userId=");
080                    sb.append(userId);
081                    sb.append(", userName=");
082                    sb.append(userName);
083                    sb.append(", createDate=");
084                    sb.append(createDate);
085                    sb.append(", modifiedDate=");
086                    sb.append(modifiedDate);
087                    sb.append(", parentFolderId=");
088                    sb.append(parentFolderId);
089                    sb.append(", treePath=");
090                    sb.append(treePath);
091                    sb.append(", name=");
092                    sb.append(name);
093                    sb.append(", description=");
094                    sb.append(description);
095                    sb.append(", restrictionType=");
096                    sb.append(restrictionType);
097                    sb.append(", status=");
098                    sb.append(status);
099                    sb.append(", statusByUserId=");
100                    sb.append(statusByUserId);
101                    sb.append(", statusByUserName=");
102                    sb.append(statusByUserName);
103                    sb.append(", statusDate=");
104                    sb.append(statusDate);
105                    sb.append("}");
106    
107                    return sb.toString();
108            }
109    
110            @Override
111            public JournalFolder toEntityModel() {
112                    JournalFolderImpl journalFolderImpl = new JournalFolderImpl();
113    
114                    if (uuid == null) {
115                            journalFolderImpl.setUuid(StringPool.BLANK);
116                    }
117                    else {
118                            journalFolderImpl.setUuid(uuid);
119                    }
120    
121                    journalFolderImpl.setFolderId(folderId);
122                    journalFolderImpl.setGroupId(groupId);
123                    journalFolderImpl.setCompanyId(companyId);
124                    journalFolderImpl.setUserId(userId);
125    
126                    if (userName == null) {
127                            journalFolderImpl.setUserName(StringPool.BLANK);
128                    }
129                    else {
130                            journalFolderImpl.setUserName(userName);
131                    }
132    
133                    if (createDate == Long.MIN_VALUE) {
134                            journalFolderImpl.setCreateDate(null);
135                    }
136                    else {
137                            journalFolderImpl.setCreateDate(new Date(createDate));
138                    }
139    
140                    if (modifiedDate == Long.MIN_VALUE) {
141                            journalFolderImpl.setModifiedDate(null);
142                    }
143                    else {
144                            journalFolderImpl.setModifiedDate(new Date(modifiedDate));
145                    }
146    
147                    journalFolderImpl.setParentFolderId(parentFolderId);
148    
149                    if (treePath == null) {
150                            journalFolderImpl.setTreePath(StringPool.BLANK);
151                    }
152                    else {
153                            journalFolderImpl.setTreePath(treePath);
154                    }
155    
156                    if (name == null) {
157                            journalFolderImpl.setName(StringPool.BLANK);
158                    }
159                    else {
160                            journalFolderImpl.setName(name);
161                    }
162    
163                    if (description == null) {
164                            journalFolderImpl.setDescription(StringPool.BLANK);
165                    }
166                    else {
167                            journalFolderImpl.setDescription(description);
168                    }
169    
170                    journalFolderImpl.setRestrictionType(restrictionType);
171                    journalFolderImpl.setStatus(status);
172                    journalFolderImpl.setStatusByUserId(statusByUserId);
173    
174                    if (statusByUserName == null) {
175                            journalFolderImpl.setStatusByUserName(StringPool.BLANK);
176                    }
177                    else {
178                            journalFolderImpl.setStatusByUserName(statusByUserName);
179                    }
180    
181                    if (statusDate == Long.MIN_VALUE) {
182                            journalFolderImpl.setStatusDate(null);
183                    }
184                    else {
185                            journalFolderImpl.setStatusDate(new Date(statusDate));
186                    }
187    
188                    journalFolderImpl.resetOriginalValues();
189    
190                    return journalFolderImpl;
191            }
192    
193            @Override
194            public void readExternal(ObjectInput objectInput) throws IOException {
195                    uuid = objectInput.readUTF();
196                    folderId = objectInput.readLong();
197                    groupId = objectInput.readLong();
198                    companyId = objectInput.readLong();
199                    userId = objectInput.readLong();
200                    userName = objectInput.readUTF();
201                    createDate = objectInput.readLong();
202                    modifiedDate = objectInput.readLong();
203                    parentFolderId = objectInput.readLong();
204                    treePath = objectInput.readUTF();
205                    name = objectInput.readUTF();
206                    description = objectInput.readUTF();
207                    restrictionType = objectInput.readInt();
208                    status = objectInput.readInt();
209                    statusByUserId = objectInput.readLong();
210                    statusByUserName = objectInput.readUTF();
211                    statusDate = objectInput.readLong();
212            }
213    
214            @Override
215            public void writeExternal(ObjectOutput objectOutput)
216                    throws IOException {
217                    if (uuid == null) {
218                            objectOutput.writeUTF(StringPool.BLANK);
219                    }
220                    else {
221                            objectOutput.writeUTF(uuid);
222                    }
223    
224                    objectOutput.writeLong(folderId);
225                    objectOutput.writeLong(groupId);
226                    objectOutput.writeLong(companyId);
227                    objectOutput.writeLong(userId);
228    
229                    if (userName == null) {
230                            objectOutput.writeUTF(StringPool.BLANK);
231                    }
232                    else {
233                            objectOutput.writeUTF(userName);
234                    }
235    
236                    objectOutput.writeLong(createDate);
237                    objectOutput.writeLong(modifiedDate);
238                    objectOutput.writeLong(parentFolderId);
239    
240                    if (treePath == null) {
241                            objectOutput.writeUTF(StringPool.BLANK);
242                    }
243                    else {
244                            objectOutput.writeUTF(treePath);
245                    }
246    
247                    if (name == null) {
248                            objectOutput.writeUTF(StringPool.BLANK);
249                    }
250                    else {
251                            objectOutput.writeUTF(name);
252                    }
253    
254                    if (description == null) {
255                            objectOutput.writeUTF(StringPool.BLANK);
256                    }
257                    else {
258                            objectOutput.writeUTF(description);
259                    }
260    
261                    objectOutput.writeInt(restrictionType);
262                    objectOutput.writeInt(status);
263                    objectOutput.writeLong(statusByUserId);
264    
265                    if (statusByUserName == null) {
266                            objectOutput.writeUTF(StringPool.BLANK);
267                    }
268                    else {
269                            objectOutput.writeUTF(statusByUserName);
270                    }
271    
272                    objectOutput.writeLong(statusDate);
273            }
274    
275            public String uuid;
276            public long folderId;
277            public long groupId;
278            public long companyId;
279            public long userId;
280            public String userName;
281            public long createDate;
282            public long modifiedDate;
283            public long parentFolderId;
284            public String treePath;
285            public String name;
286            public String description;
287            public int restrictionType;
288            public int status;
289            public long statusByUserId;
290            public String statusByUserName;
291            public long statusDate;
292    }