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