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.message.boards.kernel.model.MBDiscussion;
020    
021    import com.liferay.portal.kernel.model.CacheModel;
022    import com.liferay.portal.kernel.util.HashUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
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 MBDiscussion in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see MBDiscussion
038     * @generated
039     */
040    @ProviderType
041    public class MBDiscussionCacheModel implements CacheModel<MBDiscussion>,
042            Externalizable {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof MBDiscussionCacheModel)) {
050                            return false;
051                    }
052    
053                    MBDiscussionCacheModel mbDiscussionCacheModel = (MBDiscussionCacheModel)obj;
054    
055                    if (discussionId == mbDiscussionCacheModel.discussionId) {
056                            return true;
057                    }
058    
059                    return false;
060            }
061    
062            @Override
063            public int hashCode() {
064                    return HashUtil.hash(0, discussionId);
065            }
066    
067            @Override
068            public String toString() {
069                    StringBundler sb = new StringBundler(25);
070    
071                    sb.append("{uuid=");
072                    sb.append(uuid);
073                    sb.append(", discussionId=");
074                    sb.append(discussionId);
075                    sb.append(", groupId=");
076                    sb.append(groupId);
077                    sb.append(", companyId=");
078                    sb.append(companyId);
079                    sb.append(", userId=");
080                    sb.append(userId);
081                    sb.append(", userName=");
082                    sb.append(userName);
083                    sb.append(", createDate=");
084                    sb.append(createDate);
085                    sb.append(", modifiedDate=");
086                    sb.append(modifiedDate);
087                    sb.append(", classNameId=");
088                    sb.append(classNameId);
089                    sb.append(", classPK=");
090                    sb.append(classPK);
091                    sb.append(", threadId=");
092                    sb.append(threadId);
093                    sb.append(", lastPublishDate=");
094                    sb.append(lastPublishDate);
095                    sb.append("}");
096    
097                    return sb.toString();
098            }
099    
100            @Override
101            public MBDiscussion toEntityModel() {
102                    MBDiscussionImpl mbDiscussionImpl = new MBDiscussionImpl();
103    
104                    if (uuid == null) {
105                            mbDiscussionImpl.setUuid(StringPool.BLANK);
106                    }
107                    else {
108                            mbDiscussionImpl.setUuid(uuid);
109                    }
110    
111                    mbDiscussionImpl.setDiscussionId(discussionId);
112                    mbDiscussionImpl.setGroupId(groupId);
113                    mbDiscussionImpl.setCompanyId(companyId);
114                    mbDiscussionImpl.setUserId(userId);
115    
116                    if (userName == null) {
117                            mbDiscussionImpl.setUserName(StringPool.BLANK);
118                    }
119                    else {
120                            mbDiscussionImpl.setUserName(userName);
121                    }
122    
123                    if (createDate == Long.MIN_VALUE) {
124                            mbDiscussionImpl.setCreateDate(null);
125                    }
126                    else {
127                            mbDiscussionImpl.setCreateDate(new Date(createDate));
128                    }
129    
130                    if (modifiedDate == Long.MIN_VALUE) {
131                            mbDiscussionImpl.setModifiedDate(null);
132                    }
133                    else {
134                            mbDiscussionImpl.setModifiedDate(new Date(modifiedDate));
135                    }
136    
137                    mbDiscussionImpl.setClassNameId(classNameId);
138                    mbDiscussionImpl.setClassPK(classPK);
139                    mbDiscussionImpl.setThreadId(threadId);
140    
141                    if (lastPublishDate == Long.MIN_VALUE) {
142                            mbDiscussionImpl.setLastPublishDate(null);
143                    }
144                    else {
145                            mbDiscussionImpl.setLastPublishDate(new Date(lastPublishDate));
146                    }
147    
148                    mbDiscussionImpl.resetOriginalValues();
149    
150                    return mbDiscussionImpl;
151            }
152    
153            @Override
154            public void readExternal(ObjectInput objectInput) throws IOException {
155                    uuid = objectInput.readUTF();
156    
157                    discussionId = objectInput.readLong();
158    
159                    groupId = objectInput.readLong();
160    
161                    companyId = objectInput.readLong();
162    
163                    userId = objectInput.readLong();
164                    userName = objectInput.readUTF();
165                    createDate = objectInput.readLong();
166                    modifiedDate = objectInput.readLong();
167    
168                    classNameId = objectInput.readLong();
169    
170                    classPK = objectInput.readLong();
171    
172                    threadId = objectInput.readLong();
173                    lastPublishDate = objectInput.readLong();
174            }
175    
176            @Override
177            public void writeExternal(ObjectOutput objectOutput)
178                    throws IOException {
179                    if (uuid == null) {
180                            objectOutput.writeUTF(StringPool.BLANK);
181                    }
182                    else {
183                            objectOutput.writeUTF(uuid);
184                    }
185    
186                    objectOutput.writeLong(discussionId);
187    
188                    objectOutput.writeLong(groupId);
189    
190                    objectOutput.writeLong(companyId);
191    
192                    objectOutput.writeLong(userId);
193    
194                    if (userName == null) {
195                            objectOutput.writeUTF(StringPool.BLANK);
196                    }
197                    else {
198                            objectOutput.writeUTF(userName);
199                    }
200    
201                    objectOutput.writeLong(createDate);
202                    objectOutput.writeLong(modifiedDate);
203    
204                    objectOutput.writeLong(classNameId);
205    
206                    objectOutput.writeLong(classPK);
207    
208                    objectOutput.writeLong(threadId);
209                    objectOutput.writeLong(lastPublishDate);
210            }
211    
212            public String uuid;
213            public long discussionId;
214            public long groupId;
215            public long companyId;
216            public long userId;
217            public String userName;
218            public long createDate;
219            public long modifiedDate;
220            public long classNameId;
221            public long classPK;
222            public long threadId;
223            public long lastPublishDate;
224    }