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.MBMessage;
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                    messageId = objectInput.readLong();
231                    groupId = objectInput.readLong();
232                    companyId = objectInput.readLong();
233                    userId = objectInput.readLong();
234                    userName = objectInput.readUTF();
235                    createDate = objectInput.readLong();
236                    modifiedDate = objectInput.readLong();
237                    classNameId = objectInput.readLong();
238                    classPK = objectInput.readLong();
239                    categoryId = objectInput.readLong();
240                    threadId = objectInput.readLong();
241                    rootMessageId = objectInput.readLong();
242                    parentMessageId = objectInput.readLong();
243                    subject = objectInput.readUTF();
244                    body = objectInput.readUTF();
245                    format = objectInput.readUTF();
246                    anonymous = objectInput.readBoolean();
247                    priority = objectInput.readDouble();
248                    allowPingbacks = objectInput.readBoolean();
249                    answer = objectInput.readBoolean();
250                    lastPublishDate = objectInput.readLong();
251                    status = objectInput.readInt();
252                    statusByUserId = objectInput.readLong();
253                    statusByUserName = objectInput.readUTF();
254                    statusDate = objectInput.readLong();
255            }
256    
257            @Override
258            public void writeExternal(ObjectOutput objectOutput)
259                    throws IOException {
260                    if (uuid == null) {
261                            objectOutput.writeUTF(StringPool.BLANK);
262                    }
263                    else {
264                            objectOutput.writeUTF(uuid);
265                    }
266    
267                    objectOutput.writeLong(messageId);
268                    objectOutput.writeLong(groupId);
269                    objectOutput.writeLong(companyId);
270                    objectOutput.writeLong(userId);
271    
272                    if (userName == null) {
273                            objectOutput.writeUTF(StringPool.BLANK);
274                    }
275                    else {
276                            objectOutput.writeUTF(userName);
277                    }
278    
279                    objectOutput.writeLong(createDate);
280                    objectOutput.writeLong(modifiedDate);
281                    objectOutput.writeLong(classNameId);
282                    objectOutput.writeLong(classPK);
283                    objectOutput.writeLong(categoryId);
284                    objectOutput.writeLong(threadId);
285                    objectOutput.writeLong(rootMessageId);
286                    objectOutput.writeLong(parentMessageId);
287    
288                    if (subject == null) {
289                            objectOutput.writeUTF(StringPool.BLANK);
290                    }
291                    else {
292                            objectOutput.writeUTF(subject);
293                    }
294    
295                    if (body == null) {
296                            objectOutput.writeUTF(StringPool.BLANK);
297                    }
298                    else {
299                            objectOutput.writeUTF(body);
300                    }
301    
302                    if (format == null) {
303                            objectOutput.writeUTF(StringPool.BLANK);
304                    }
305                    else {
306                            objectOutput.writeUTF(format);
307                    }
308    
309                    objectOutput.writeBoolean(anonymous);
310                    objectOutput.writeDouble(priority);
311                    objectOutput.writeBoolean(allowPingbacks);
312                    objectOutput.writeBoolean(answer);
313                    objectOutput.writeLong(lastPublishDate);
314                    objectOutput.writeInt(status);
315                    objectOutput.writeLong(statusByUserId);
316    
317                    if (statusByUserName == null) {
318                            objectOutput.writeUTF(StringPool.BLANK);
319                    }
320                    else {
321                            objectOutput.writeUTF(statusByUserName);
322                    }
323    
324                    objectOutput.writeLong(statusDate);
325            }
326    
327            public String uuid;
328            public long messageId;
329            public long groupId;
330            public long companyId;
331            public long userId;
332            public String userName;
333            public long createDate;
334            public long modifiedDate;
335            public long classNameId;
336            public long classPK;
337            public long categoryId;
338            public long threadId;
339            public long rootMessageId;
340            public long parentMessageId;
341            public String subject;
342            public String body;
343            public String format;
344            public boolean anonymous;
345            public double priority;
346            public boolean allowPingbacks;
347            public boolean answer;
348            public long lastPublishDate;
349            public int status;
350            public long statusByUserId;
351            public String statusByUserName;
352            public long statusDate;
353    }