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