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(51);
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(", status=");
114                    sb.append(status);
115                    sb.append(", statusByUserId=");
116                    sb.append(statusByUserId);
117                    sb.append(", statusByUserName=");
118                    sb.append(statusByUserName);
119                    sb.append(", statusDate=");
120                    sb.append(statusDate);
121                    sb.append("}");
122    
123                    return sb.toString();
124            }
125    
126            @Override
127            public MBMessage toEntityModel() {
128                    MBMessageImpl mbMessageImpl = new MBMessageImpl();
129    
130                    if (uuid == null) {
131                            mbMessageImpl.setUuid(StringPool.BLANK);
132                    }
133                    else {
134                            mbMessageImpl.setUuid(uuid);
135                    }
136    
137                    mbMessageImpl.setMessageId(messageId);
138                    mbMessageImpl.setGroupId(groupId);
139                    mbMessageImpl.setCompanyId(companyId);
140                    mbMessageImpl.setUserId(userId);
141    
142                    if (userName == null) {
143                            mbMessageImpl.setUserName(StringPool.BLANK);
144                    }
145                    else {
146                            mbMessageImpl.setUserName(userName);
147                    }
148    
149                    if (createDate == Long.MIN_VALUE) {
150                            mbMessageImpl.setCreateDate(null);
151                    }
152                    else {
153                            mbMessageImpl.setCreateDate(new Date(createDate));
154                    }
155    
156                    if (modifiedDate == Long.MIN_VALUE) {
157                            mbMessageImpl.setModifiedDate(null);
158                    }
159                    else {
160                            mbMessageImpl.setModifiedDate(new Date(modifiedDate));
161                    }
162    
163                    mbMessageImpl.setClassNameId(classNameId);
164                    mbMessageImpl.setClassPK(classPK);
165                    mbMessageImpl.setCategoryId(categoryId);
166                    mbMessageImpl.setThreadId(threadId);
167                    mbMessageImpl.setRootMessageId(rootMessageId);
168                    mbMessageImpl.setParentMessageId(parentMessageId);
169    
170                    if (subject == null) {
171                            mbMessageImpl.setSubject(StringPool.BLANK);
172                    }
173                    else {
174                            mbMessageImpl.setSubject(subject);
175                    }
176    
177                    if (body == null) {
178                            mbMessageImpl.setBody(StringPool.BLANK);
179                    }
180                    else {
181                            mbMessageImpl.setBody(body);
182                    }
183    
184                    if (format == null) {
185                            mbMessageImpl.setFormat(StringPool.BLANK);
186                    }
187                    else {
188                            mbMessageImpl.setFormat(format);
189                    }
190    
191                    mbMessageImpl.setAnonymous(anonymous);
192                    mbMessageImpl.setPriority(priority);
193                    mbMessageImpl.setAllowPingbacks(allowPingbacks);
194                    mbMessageImpl.setAnswer(answer);
195                    mbMessageImpl.setStatus(status);
196                    mbMessageImpl.setStatusByUserId(statusByUserId);
197    
198                    if (statusByUserName == null) {
199                            mbMessageImpl.setStatusByUserName(StringPool.BLANK);
200                    }
201                    else {
202                            mbMessageImpl.setStatusByUserName(statusByUserName);
203                    }
204    
205                    if (statusDate == Long.MIN_VALUE) {
206                            mbMessageImpl.setStatusDate(null);
207                    }
208                    else {
209                            mbMessageImpl.setStatusDate(new Date(statusDate));
210                    }
211    
212                    mbMessageImpl.resetOriginalValues();
213    
214                    return mbMessageImpl;
215            }
216    
217            @Override
218            public void readExternal(ObjectInput objectInput) throws IOException {
219                    uuid = objectInput.readUTF();
220                    messageId = objectInput.readLong();
221                    groupId = objectInput.readLong();
222                    companyId = objectInput.readLong();
223                    userId = objectInput.readLong();
224                    userName = objectInput.readUTF();
225                    createDate = objectInput.readLong();
226                    modifiedDate = objectInput.readLong();
227                    classNameId = objectInput.readLong();
228                    classPK = objectInput.readLong();
229                    categoryId = objectInput.readLong();
230                    threadId = objectInput.readLong();
231                    rootMessageId = objectInput.readLong();
232                    parentMessageId = objectInput.readLong();
233                    subject = objectInput.readUTF();
234                    body = objectInput.readUTF();
235                    format = objectInput.readUTF();
236                    anonymous = objectInput.readBoolean();
237                    priority = objectInput.readDouble();
238                    allowPingbacks = objectInput.readBoolean();
239                    answer = objectInput.readBoolean();
240                    status = objectInput.readInt();
241                    statusByUserId = objectInput.readLong();
242                    statusByUserName = objectInput.readUTF();
243                    statusDate = objectInput.readLong();
244            }
245    
246            @Override
247            public void writeExternal(ObjectOutput objectOutput)
248                    throws IOException {
249                    if (uuid == null) {
250                            objectOutput.writeUTF(StringPool.BLANK);
251                    }
252                    else {
253                            objectOutput.writeUTF(uuid);
254                    }
255    
256                    objectOutput.writeLong(messageId);
257                    objectOutput.writeLong(groupId);
258                    objectOutput.writeLong(companyId);
259                    objectOutput.writeLong(userId);
260    
261                    if (userName == null) {
262                            objectOutput.writeUTF(StringPool.BLANK);
263                    }
264                    else {
265                            objectOutput.writeUTF(userName);
266                    }
267    
268                    objectOutput.writeLong(createDate);
269                    objectOutput.writeLong(modifiedDate);
270                    objectOutput.writeLong(classNameId);
271                    objectOutput.writeLong(classPK);
272                    objectOutput.writeLong(categoryId);
273                    objectOutput.writeLong(threadId);
274                    objectOutput.writeLong(rootMessageId);
275                    objectOutput.writeLong(parentMessageId);
276    
277                    if (subject == null) {
278                            objectOutput.writeUTF(StringPool.BLANK);
279                    }
280                    else {
281                            objectOutput.writeUTF(subject);
282                    }
283    
284                    if (body == null) {
285                            objectOutput.writeUTF(StringPool.BLANK);
286                    }
287                    else {
288                            objectOutput.writeUTF(body);
289                    }
290    
291                    if (format == null) {
292                            objectOutput.writeUTF(StringPool.BLANK);
293                    }
294                    else {
295                            objectOutput.writeUTF(format);
296                    }
297    
298                    objectOutput.writeBoolean(anonymous);
299                    objectOutput.writeDouble(priority);
300                    objectOutput.writeBoolean(allowPingbacks);
301                    objectOutput.writeBoolean(answer);
302                    objectOutput.writeInt(status);
303                    objectOutput.writeLong(statusByUserId);
304    
305                    if (statusByUserName == null) {
306                            objectOutput.writeUTF(StringPool.BLANK);
307                    }
308                    else {
309                            objectOutput.writeUTF(statusByUserName);
310                    }
311    
312                    objectOutput.writeLong(statusDate);
313            }
314    
315            public String uuid;
316            public long messageId;
317            public long groupId;
318            public long companyId;
319            public long userId;
320            public String userName;
321            public long createDate;
322            public long modifiedDate;
323            public long classNameId;
324            public long classPK;
325            public long categoryId;
326            public long threadId;
327            public long rootMessageId;
328            public long parentMessageId;
329            public String subject;
330            public String body;
331            public String format;
332            public boolean anonymous;
333            public double priority;
334            public boolean allowPingbacks;
335            public boolean answer;
336            public int status;
337            public long statusByUserId;
338            public String statusByUserName;
339            public long statusDate;
340    }