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