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.announcements.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.announcements.model.AnnouncementsEntry;
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 AnnouncementsEntry in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see AnnouncementsEntry
035     * @generated
036     */
037    public class AnnouncementsEntryCacheModel implements CacheModel<AnnouncementsEntry>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(35);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", entryId=");
046                    sb.append(entryId);
047                    sb.append(", companyId=");
048                    sb.append(companyId);
049                    sb.append(", userId=");
050                    sb.append(userId);
051                    sb.append(", userName=");
052                    sb.append(userName);
053                    sb.append(", createDate=");
054                    sb.append(createDate);
055                    sb.append(", modifiedDate=");
056                    sb.append(modifiedDate);
057                    sb.append(", classNameId=");
058                    sb.append(classNameId);
059                    sb.append(", classPK=");
060                    sb.append(classPK);
061                    sb.append(", title=");
062                    sb.append(title);
063                    sb.append(", content=");
064                    sb.append(content);
065                    sb.append(", url=");
066                    sb.append(url);
067                    sb.append(", type=");
068                    sb.append(type);
069                    sb.append(", displayDate=");
070                    sb.append(displayDate);
071                    sb.append(", expirationDate=");
072                    sb.append(expirationDate);
073                    sb.append(", priority=");
074                    sb.append(priority);
075                    sb.append(", alert=");
076                    sb.append(alert);
077                    sb.append("}");
078    
079                    return sb.toString();
080            }
081    
082            @Override
083            public AnnouncementsEntry toEntityModel() {
084                    AnnouncementsEntryImpl announcementsEntryImpl = new AnnouncementsEntryImpl();
085    
086                    if (uuid == null) {
087                            announcementsEntryImpl.setUuid(StringPool.BLANK);
088                    }
089                    else {
090                            announcementsEntryImpl.setUuid(uuid);
091                    }
092    
093                    announcementsEntryImpl.setEntryId(entryId);
094                    announcementsEntryImpl.setCompanyId(companyId);
095                    announcementsEntryImpl.setUserId(userId);
096    
097                    if (userName == null) {
098                            announcementsEntryImpl.setUserName(StringPool.BLANK);
099                    }
100                    else {
101                            announcementsEntryImpl.setUserName(userName);
102                    }
103    
104                    if (createDate == Long.MIN_VALUE) {
105                            announcementsEntryImpl.setCreateDate(null);
106                    }
107                    else {
108                            announcementsEntryImpl.setCreateDate(new Date(createDate));
109                    }
110    
111                    if (modifiedDate == Long.MIN_VALUE) {
112                            announcementsEntryImpl.setModifiedDate(null);
113                    }
114                    else {
115                            announcementsEntryImpl.setModifiedDate(new Date(modifiedDate));
116                    }
117    
118                    announcementsEntryImpl.setClassNameId(classNameId);
119                    announcementsEntryImpl.setClassPK(classPK);
120    
121                    if (title == null) {
122                            announcementsEntryImpl.setTitle(StringPool.BLANK);
123                    }
124                    else {
125                            announcementsEntryImpl.setTitle(title);
126                    }
127    
128                    if (content == null) {
129                            announcementsEntryImpl.setContent(StringPool.BLANK);
130                    }
131                    else {
132                            announcementsEntryImpl.setContent(content);
133                    }
134    
135                    if (url == null) {
136                            announcementsEntryImpl.setUrl(StringPool.BLANK);
137                    }
138                    else {
139                            announcementsEntryImpl.setUrl(url);
140                    }
141    
142                    if (type == null) {
143                            announcementsEntryImpl.setType(StringPool.BLANK);
144                    }
145                    else {
146                            announcementsEntryImpl.setType(type);
147                    }
148    
149                    if (displayDate == Long.MIN_VALUE) {
150                            announcementsEntryImpl.setDisplayDate(null);
151                    }
152                    else {
153                            announcementsEntryImpl.setDisplayDate(new Date(displayDate));
154                    }
155    
156                    if (expirationDate == Long.MIN_VALUE) {
157                            announcementsEntryImpl.setExpirationDate(null);
158                    }
159                    else {
160                            announcementsEntryImpl.setExpirationDate(new Date(expirationDate));
161                    }
162    
163                    announcementsEntryImpl.setPriority(priority);
164                    announcementsEntryImpl.setAlert(alert);
165    
166                    announcementsEntryImpl.resetOriginalValues();
167    
168                    return announcementsEntryImpl;
169            }
170    
171            @Override
172            public void readExternal(ObjectInput objectInput) throws IOException {
173                    uuid = objectInput.readUTF();
174                    entryId = objectInput.readLong();
175                    companyId = objectInput.readLong();
176                    userId = objectInput.readLong();
177                    userName = objectInput.readUTF();
178                    createDate = objectInput.readLong();
179                    modifiedDate = objectInput.readLong();
180                    classNameId = objectInput.readLong();
181                    classPK = objectInput.readLong();
182                    title = objectInput.readUTF();
183                    content = objectInput.readUTF();
184                    url = objectInput.readUTF();
185                    type = objectInput.readUTF();
186                    displayDate = objectInput.readLong();
187                    expirationDate = objectInput.readLong();
188                    priority = objectInput.readInt();
189                    alert = objectInput.readBoolean();
190            }
191    
192            @Override
193            public void writeExternal(ObjectOutput objectOutput)
194                    throws IOException {
195                    if (uuid == null) {
196                            objectOutput.writeUTF(StringPool.BLANK);
197                    }
198                    else {
199                            objectOutput.writeUTF(uuid);
200                    }
201    
202                    objectOutput.writeLong(entryId);
203                    objectOutput.writeLong(companyId);
204                    objectOutput.writeLong(userId);
205    
206                    if (userName == null) {
207                            objectOutput.writeUTF(StringPool.BLANK);
208                    }
209                    else {
210                            objectOutput.writeUTF(userName);
211                    }
212    
213                    objectOutput.writeLong(createDate);
214                    objectOutput.writeLong(modifiedDate);
215                    objectOutput.writeLong(classNameId);
216                    objectOutput.writeLong(classPK);
217    
218                    if (title == null) {
219                            objectOutput.writeUTF(StringPool.BLANK);
220                    }
221                    else {
222                            objectOutput.writeUTF(title);
223                    }
224    
225                    if (content == null) {
226                            objectOutput.writeUTF(StringPool.BLANK);
227                    }
228                    else {
229                            objectOutput.writeUTF(content);
230                    }
231    
232                    if (url == null) {
233                            objectOutput.writeUTF(StringPool.BLANK);
234                    }
235                    else {
236                            objectOutput.writeUTF(url);
237                    }
238    
239                    if (type == null) {
240                            objectOutput.writeUTF(StringPool.BLANK);
241                    }
242                    else {
243                            objectOutput.writeUTF(type);
244                    }
245    
246                    objectOutput.writeLong(displayDate);
247                    objectOutput.writeLong(expirationDate);
248                    objectOutput.writeInt(priority);
249                    objectOutput.writeBoolean(alert);
250            }
251    
252            public String uuid;
253            public long entryId;
254            public long companyId;
255            public long userId;
256            public String userName;
257            public long createDate;
258            public long modifiedDate;
259            public long classNameId;
260            public long classPK;
261            public String title;
262            public String content;
263            public String url;
264            public String type;
265            public long displayDate;
266            public long expirationDate;
267            public int priority;
268            public boolean alert;
269    }