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