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