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.MBMessage;
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 MBMessage in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see MBMessage
038     * @generated
039     */
040    @ProviderType
041    public class MBMessageCacheModel implements CacheModel<MBMessage>,
042            Externalizable {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof MBMessageCacheModel)) {
050                            return false;
051                    }
052    
053                    MBMessageCacheModel mbMessageCacheModel = (MBMessageCacheModel)obj;
054    
055                    if (messageId == mbMessageCacheModel.messageId) {
056                            return true;
057                    }
058    
059                    return false;
060            }
061    
062            @Override
063            public int hashCode() {
064                    return HashUtil.hash(0, messageId);
065            }
066    
067            @Override
068            public String toString() {
069                    StringBundler sb = new StringBundler(53);
070    
071                    sb.append("{uuid=");
072                    sb.append(uuid);
073                    sb.append(", messageId=");
074                    sb.append(messageId);
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(", classNameId=");
088                    sb.append(classNameId);
089                    sb.append(", classPK=");
090                    sb.append(classPK);
091                    sb.append(", categoryId=");
092                    sb.append(categoryId);
093                    sb.append(", threadId=");
094                    sb.append(threadId);
095                    sb.append(", rootMessageId=");
096                    sb.append(rootMessageId);
097                    sb.append(", parentMessageId=");
098                    sb.append(parentMessageId);
099                    sb.append(", subject=");
100                    sb.append(subject);
101                    sb.append(", body=");
102                    sb.append(body);
103                    sb.append(", format=");
104                    sb.append(format);
105                    sb.append(", anonymous=");
106                    sb.append(anonymous);
107                    sb.append(", priority=");
108                    sb.append(priority);
109                    sb.append(", allowPingbacks=");
110                    sb.append(allowPingbacks);
111                    sb.append(", answer=");
112                    sb.append(answer);
113                    sb.append(", lastPublishDate=");
114                    sb.append(lastPublishDate);
115                    sb.append(", status=");
116                    sb.append(status);
117                    sb.append(", statusByUserId=");
118                    sb.append(statusByUserId);
119                    sb.append(", statusByUserName=");
120                    sb.append(statusByUserName);
121                    sb.append(", statusDate=");
122                    sb.append(statusDate);
123                    sb.append("}");
124    
125                    return sb.toString();
126            }
127    
128            @Override
129            public MBMessage toEntityModel() {
130                    MBMessageImpl mbMessageImpl = new MBMessageImpl();
131    
132                    if (uuid == null) {
133                            mbMessageImpl.setUuid(StringPool.BLANK);
134                    }
135                    else {
136                            mbMessageImpl.setUuid(uuid);
137                    }
138    
139                    mbMessageImpl.setMessageId(messageId);
140                    mbMessageImpl.setGroupId(groupId);
141                    mbMessageImpl.setCompanyId(companyId);
142                    mbMessageImpl.setUserId(userId);
143    
144                    if (userName == null) {
145                            mbMessageImpl.setUserName(StringPool.BLANK);
146                    }
147                    else {
148                            mbMessageImpl.setUserName(userName);
149                    }
150    
151                    if (createDate == Long.MIN_VALUE) {
152                            mbMessageImpl.setCreateDate(null);
153                    }
154                    else {
155                            mbMessageImpl.setCreateDate(new Date(createDate));
156                    }
157    
158                    if (modifiedDate == Long.MIN_VALUE) {
159                            mbMessageImpl.setModifiedDate(null);
160                    }
161                    else {
162                            mbMessageImpl.setModifiedDate(new Date(modifiedDate));
163                    }
164    
165                    mbMessageImpl.setClassNameId(classNameId);
166                    mbMessageImpl.setClassPK(classPK);
167                    mbMessageImpl.setCategoryId(categoryId);
168                    mbMessageImpl.setThreadId(threadId);
169                    mbMessageImpl.setRootMessageId(rootMessageId);
170                    mbMessageImpl.setParentMessageId(parentMessageId);
171    
172                    if (subject == null) {
173                            mbMessageImpl.setSubject(StringPool.BLANK);
174                    }
175                    else {
176                            mbMessageImpl.setSubject(subject);
177                    }
178    
179                    if (body == null) {
180                            mbMessageImpl.setBody(StringPool.BLANK);
181                    }
182                    else {
183                            mbMessageImpl.setBody(body);
184                    }
185    
186                    if (format == null) {
187                            mbMessageImpl.setFormat(StringPool.BLANK);
188                    }
189                    else {
190                            mbMessageImpl.setFormat(format);
191                    }
192    
193                    mbMessageImpl.setAnonymous(anonymous);
194                    mbMessageImpl.setPriority(priority);
195                    mbMessageImpl.setAllowPingbacks(allowPingbacks);
196                    mbMessageImpl.setAnswer(answer);
197    
198                    if (lastPublishDate == Long.MIN_VALUE) {
199                            mbMessageImpl.setLastPublishDate(null);
200                    }
201                    else {
202                            mbMessageImpl.setLastPublishDate(new Date(lastPublishDate));
203                    }
204    
205                    mbMessageImpl.setStatus(status);
206                    mbMessageImpl.setStatusByUserId(statusByUserId);
207    
208                    if (statusByUserName == null) {
209                            mbMessageImpl.setStatusByUserName(StringPool.BLANK);
210                    }
211                    else {
212                            mbMessageImpl.setStatusByUserName(statusByUserName);
213                    }
214    
215                    if (statusDate == Long.MIN_VALUE) {
216                            mbMessageImpl.setStatusDate(null);
217                    }
218                    else {
219                            mbMessageImpl.setStatusDate(new Date(statusDate));
220                    }
221    
222                    mbMessageImpl.resetOriginalValues();
223    
224                    return mbMessageImpl;
225            }
226    
227            @Override
228            public void readExternal(ObjectInput objectInput) throws IOException {
229                    uuid = objectInput.readUTF();
230    
231                    messageId = objectInput.readLong();
232    
233                    groupId = objectInput.readLong();
234    
235                    companyId = objectInput.readLong();
236    
237                    userId = objectInput.readLong();
238                    userName = objectInput.readUTF();
239                    createDate = objectInput.readLong();
240                    modifiedDate = objectInput.readLong();
241    
242                    classNameId = objectInput.readLong();
243    
244                    classPK = objectInput.readLong();
245    
246                    categoryId = objectInput.readLong();
247    
248                    threadId = objectInput.readLong();
249    
250                    rootMessageId = objectInput.readLong();
251    
252                    parentMessageId = objectInput.readLong();
253                    subject = objectInput.readUTF();
254                    body = objectInput.readUTF();
255                    format = objectInput.readUTF();
256    
257                    anonymous = objectInput.readBoolean();
258    
259                    priority = objectInput.readDouble();
260    
261                    allowPingbacks = objectInput.readBoolean();
262    
263                    answer = objectInput.readBoolean();
264                    lastPublishDate = objectInput.readLong();
265    
266                    status = objectInput.readInt();
267    
268                    statusByUserId = objectInput.readLong();
269                    statusByUserName = objectInput.readUTF();
270                    statusDate = objectInput.readLong();
271            }
272    
273            @Override
274            public void writeExternal(ObjectOutput objectOutput)
275                    throws IOException {
276                    if (uuid == null) {
277                            objectOutput.writeUTF(StringPool.BLANK);
278                    }
279                    else {
280                            objectOutput.writeUTF(uuid);
281                    }
282    
283                    objectOutput.writeLong(messageId);
284    
285                    objectOutput.writeLong(groupId);
286    
287                    objectOutput.writeLong(companyId);
288    
289                    objectOutput.writeLong(userId);
290    
291                    if (userName == null) {
292                            objectOutput.writeUTF(StringPool.BLANK);
293                    }
294                    else {
295                            objectOutput.writeUTF(userName);
296                    }
297    
298                    objectOutput.writeLong(createDate);
299                    objectOutput.writeLong(modifiedDate);
300    
301                    objectOutput.writeLong(classNameId);
302    
303                    objectOutput.writeLong(classPK);
304    
305                    objectOutput.writeLong(categoryId);
306    
307                    objectOutput.writeLong(threadId);
308    
309                    objectOutput.writeLong(rootMessageId);
310    
311                    objectOutput.writeLong(parentMessageId);
312    
313                    if (subject == null) {
314                            objectOutput.writeUTF(StringPool.BLANK);
315                    }
316                    else {
317                            objectOutput.writeUTF(subject);
318                    }
319    
320                    if (body == null) {
321                            objectOutput.writeUTF(StringPool.BLANK);
322                    }
323                    else {
324                            objectOutput.writeUTF(body);
325                    }
326    
327                    if (format == null) {
328                            objectOutput.writeUTF(StringPool.BLANK);
329                    }
330                    else {
331                            objectOutput.writeUTF(format);
332                    }
333    
334                    objectOutput.writeBoolean(anonymous);
335    
336                    objectOutput.writeDouble(priority);
337    
338                    objectOutput.writeBoolean(allowPingbacks);
339    
340                    objectOutput.writeBoolean(answer);
341                    objectOutput.writeLong(lastPublishDate);
342    
343                    objectOutput.writeInt(status);
344    
345                    objectOutput.writeLong(statusByUserId);
346    
347                    if (statusByUserName == null) {
348                            objectOutput.writeUTF(StringPool.BLANK);
349                    }
350                    else {
351                            objectOutput.writeUTF(statusByUserName);
352                    }
353    
354                    objectOutput.writeLong(statusDate);
355            }
356    
357            public String uuid;
358            public long messageId;
359            public long groupId;
360            public long companyId;
361            public long userId;
362            public String userName;
363            public long createDate;
364            public long modifiedDate;
365            public long classNameId;
366            public long classPK;
367            public long categoryId;
368            public long threadId;
369            public long rootMessageId;
370            public long parentMessageId;
371            public String subject;
372            public String body;
373            public String format;
374            public boolean anonymous;
375            public double priority;
376            public boolean allowPingbacks;
377            public boolean answer;
378            public long lastPublishDate;
379            public int status;
380            public long statusByUserId;
381            public String statusByUserName;
382            public long statusDate;
383    }