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            public AnnouncementsEntry toEntityModel() {
083                    AnnouncementsEntryImpl announcementsEntryImpl = new AnnouncementsEntryImpl();
084    
085                    if (uuid == null) {
086                            announcementsEntryImpl.setUuid(StringPool.BLANK);
087                    }
088                    else {
089                            announcementsEntryImpl.setUuid(uuid);
090                    }
091    
092                    announcementsEntryImpl.setEntryId(entryId);
093                    announcementsEntryImpl.setCompanyId(companyId);
094                    announcementsEntryImpl.setUserId(userId);
095    
096                    if (userName == null) {
097                            announcementsEntryImpl.setUserName(StringPool.BLANK);
098                    }
099                    else {
100                            announcementsEntryImpl.setUserName(userName);
101                    }
102    
103                    if (createDate == Long.MIN_VALUE) {
104                            announcementsEntryImpl.setCreateDate(null);
105                    }
106                    else {
107                            announcementsEntryImpl.setCreateDate(new Date(createDate));
108                    }
109    
110                    if (modifiedDate == Long.MIN_VALUE) {
111                            announcementsEntryImpl.setModifiedDate(null);
112                    }
113                    else {
114                            announcementsEntryImpl.setModifiedDate(new Date(modifiedDate));
115                    }
116    
117                    announcementsEntryImpl.setClassNameId(classNameId);
118                    announcementsEntryImpl.setClassPK(classPK);
119    
120                    if (title == null) {
121                            announcementsEntryImpl.setTitle(StringPool.BLANK);
122                    }
123                    else {
124                            announcementsEntryImpl.setTitle(title);
125                    }
126    
127                    if (content == null) {
128                            announcementsEntryImpl.setContent(StringPool.BLANK);
129                    }
130                    else {
131                            announcementsEntryImpl.setContent(content);
132                    }
133    
134                    if (url == null) {
135                            announcementsEntryImpl.setUrl(StringPool.BLANK);
136                    }
137                    else {
138                            announcementsEntryImpl.setUrl(url);
139                    }
140    
141                    if (type == null) {
142                            announcementsEntryImpl.setType(StringPool.BLANK);
143                    }
144                    else {
145                            announcementsEntryImpl.setType(type);
146                    }
147    
148                    if (displayDate == Long.MIN_VALUE) {
149                            announcementsEntryImpl.setDisplayDate(null);
150                    }
151                    else {
152                            announcementsEntryImpl.setDisplayDate(new Date(displayDate));
153                    }
154    
155                    if (expirationDate == Long.MIN_VALUE) {
156                            announcementsEntryImpl.setExpirationDate(null);
157                    }
158                    else {
159                            announcementsEntryImpl.setExpirationDate(new Date(expirationDate));
160                    }
161    
162                    announcementsEntryImpl.setPriority(priority);
163                    announcementsEntryImpl.setAlert(alert);
164    
165                    announcementsEntryImpl.resetOriginalValues();
166    
167                    return announcementsEntryImpl;
168            }
169    
170            public void readExternal(ObjectInput objectInput) throws IOException {
171                    uuid = objectInput.readUTF();
172                    entryId = objectInput.readLong();
173                    companyId = objectInput.readLong();
174                    userId = objectInput.readLong();
175                    userName = objectInput.readUTF();
176                    createDate = objectInput.readLong();
177                    modifiedDate = objectInput.readLong();
178                    classNameId = objectInput.readLong();
179                    classPK = objectInput.readLong();
180                    title = objectInput.readUTF();
181                    content = objectInput.readUTF();
182                    url = objectInput.readUTF();
183                    type = objectInput.readUTF();
184                    displayDate = objectInput.readLong();
185                    expirationDate = objectInput.readLong();
186                    priority = objectInput.readInt();
187                    alert = objectInput.readBoolean();
188            }
189    
190            public void writeExternal(ObjectOutput objectOutput)
191                    throws IOException {
192                    if (uuid == null) {
193                            objectOutput.writeUTF(StringPool.BLANK);
194                    }
195                    else {
196                            objectOutput.writeUTF(uuid);
197                    }
198    
199                    objectOutput.writeLong(entryId);
200                    objectOutput.writeLong(companyId);
201                    objectOutput.writeLong(userId);
202    
203                    if (userName == null) {
204                            objectOutput.writeUTF(StringPool.BLANK);
205                    }
206                    else {
207                            objectOutput.writeUTF(userName);
208                    }
209    
210                    objectOutput.writeLong(createDate);
211                    objectOutput.writeLong(modifiedDate);
212                    objectOutput.writeLong(classNameId);
213                    objectOutput.writeLong(classPK);
214    
215                    if (title == null) {
216                            objectOutput.writeUTF(StringPool.BLANK);
217                    }
218                    else {
219                            objectOutput.writeUTF(title);
220                    }
221    
222                    if (content == null) {
223                            objectOutput.writeUTF(StringPool.BLANK);
224                    }
225                    else {
226                            objectOutput.writeUTF(content);
227                    }
228    
229                    if (url == null) {
230                            objectOutput.writeUTF(StringPool.BLANK);
231                    }
232                    else {
233                            objectOutput.writeUTF(url);
234                    }
235    
236                    if (type == null) {
237                            objectOutput.writeUTF(StringPool.BLANK);
238                    }
239                    else {
240                            objectOutput.writeUTF(type);
241                    }
242    
243                    objectOutput.writeLong(displayDate);
244                    objectOutput.writeLong(expirationDate);
245                    objectOutput.writeInt(priority);
246                    objectOutput.writeBoolean(alert);
247            }
248    
249            public String uuid;
250            public long entryId;
251            public long companyId;
252            public long userId;
253            public String userName;
254            public long createDate;
255            public long modifiedDate;
256            public long classNameId;
257            public long classPK;
258            public String title;
259            public String content;
260            public String url;
261            public String type;
262            public long displayDate;
263            public long expirationDate;
264            public int priority;
265            public boolean alert;
266    }