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