001
014
015 package com.liferay.portlet.messageboards.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.messageboards.model.MBThread;
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
040 @ProviderType
041 public class MBThreadCacheModel implements CacheModel<MBThread>, Externalizable {
042 @Override
043 public boolean equals(Object obj) {
044 if (this == obj) {
045 return true;
046 }
047
048 if (!(obj instanceof MBThreadCacheModel)) {
049 return false;
050 }
051
052 MBThreadCacheModel mbThreadCacheModel = (MBThreadCacheModel)obj;
053
054 if (threadId == mbThreadCacheModel.threadId) {
055 return true;
056 }
057
058 return false;
059 }
060
061 @Override
062 public int hashCode() {
063 return HashUtil.hash(0, threadId);
064 }
065
066 @Override
067 public String toString() {
068 StringBundler sb = new StringBundler(43);
069
070 sb.append("{uuid=");
071 sb.append(uuid);
072 sb.append(", threadId=");
073 sb.append(threadId);
074 sb.append(", groupId=");
075 sb.append(groupId);
076 sb.append(", companyId=");
077 sb.append(companyId);
078 sb.append(", userId=");
079 sb.append(userId);
080 sb.append(", userName=");
081 sb.append(userName);
082 sb.append(", createDate=");
083 sb.append(createDate);
084 sb.append(", modifiedDate=");
085 sb.append(modifiedDate);
086 sb.append(", categoryId=");
087 sb.append(categoryId);
088 sb.append(", rootMessageId=");
089 sb.append(rootMessageId);
090 sb.append(", rootMessageUserId=");
091 sb.append(rootMessageUserId);
092 sb.append(", messageCount=");
093 sb.append(messageCount);
094 sb.append(", viewCount=");
095 sb.append(viewCount);
096 sb.append(", lastPostByUserId=");
097 sb.append(lastPostByUserId);
098 sb.append(", lastPostDate=");
099 sb.append(lastPostDate);
100 sb.append(", priority=");
101 sb.append(priority);
102 sb.append(", question=");
103 sb.append(question);
104 sb.append(", status=");
105 sb.append(status);
106 sb.append(", statusByUserId=");
107 sb.append(statusByUserId);
108 sb.append(", statusByUserName=");
109 sb.append(statusByUserName);
110 sb.append(", statusDate=");
111 sb.append(statusDate);
112 sb.append("}");
113
114 return sb.toString();
115 }
116
117 @Override
118 public MBThread toEntityModel() {
119 MBThreadImpl mbThreadImpl = new MBThreadImpl();
120
121 if (uuid == null) {
122 mbThreadImpl.setUuid(StringPool.BLANK);
123 }
124 else {
125 mbThreadImpl.setUuid(uuid);
126 }
127
128 mbThreadImpl.setThreadId(threadId);
129 mbThreadImpl.setGroupId(groupId);
130 mbThreadImpl.setCompanyId(companyId);
131 mbThreadImpl.setUserId(userId);
132
133 if (userName == null) {
134 mbThreadImpl.setUserName(StringPool.BLANK);
135 }
136 else {
137 mbThreadImpl.setUserName(userName);
138 }
139
140 if (createDate == Long.MIN_VALUE) {
141 mbThreadImpl.setCreateDate(null);
142 }
143 else {
144 mbThreadImpl.setCreateDate(new Date(createDate));
145 }
146
147 if (modifiedDate == Long.MIN_VALUE) {
148 mbThreadImpl.setModifiedDate(null);
149 }
150 else {
151 mbThreadImpl.setModifiedDate(new Date(modifiedDate));
152 }
153
154 mbThreadImpl.setCategoryId(categoryId);
155 mbThreadImpl.setRootMessageId(rootMessageId);
156 mbThreadImpl.setRootMessageUserId(rootMessageUserId);
157 mbThreadImpl.setMessageCount(messageCount);
158 mbThreadImpl.setViewCount(viewCount);
159 mbThreadImpl.setLastPostByUserId(lastPostByUserId);
160
161 if (lastPostDate == Long.MIN_VALUE) {
162 mbThreadImpl.setLastPostDate(null);
163 }
164 else {
165 mbThreadImpl.setLastPostDate(new Date(lastPostDate));
166 }
167
168 mbThreadImpl.setPriority(priority);
169 mbThreadImpl.setQuestion(question);
170 mbThreadImpl.setStatus(status);
171 mbThreadImpl.setStatusByUserId(statusByUserId);
172
173 if (statusByUserName == null) {
174 mbThreadImpl.setStatusByUserName(StringPool.BLANK);
175 }
176 else {
177 mbThreadImpl.setStatusByUserName(statusByUserName);
178 }
179
180 if (statusDate == Long.MIN_VALUE) {
181 mbThreadImpl.setStatusDate(null);
182 }
183 else {
184 mbThreadImpl.setStatusDate(new Date(statusDate));
185 }
186
187 mbThreadImpl.resetOriginalValues();
188
189 return mbThreadImpl;
190 }
191
192 @Override
193 public void readExternal(ObjectInput objectInput) throws IOException {
194 uuid = objectInput.readUTF();
195 threadId = objectInput.readLong();
196 groupId = objectInput.readLong();
197 companyId = objectInput.readLong();
198 userId = objectInput.readLong();
199 userName = objectInput.readUTF();
200 createDate = objectInput.readLong();
201 modifiedDate = objectInput.readLong();
202 categoryId = objectInput.readLong();
203 rootMessageId = objectInput.readLong();
204 rootMessageUserId = objectInput.readLong();
205 messageCount = objectInput.readInt();
206 viewCount = objectInput.readInt();
207 lastPostByUserId = objectInput.readLong();
208 lastPostDate = objectInput.readLong();
209 priority = objectInput.readDouble();
210 question = objectInput.readBoolean();
211 status = objectInput.readInt();
212 statusByUserId = objectInput.readLong();
213 statusByUserName = objectInput.readUTF();
214 statusDate = objectInput.readLong();
215 }
216
217 @Override
218 public void writeExternal(ObjectOutput objectOutput)
219 throws IOException {
220 if (uuid == null) {
221 objectOutput.writeUTF(StringPool.BLANK);
222 }
223 else {
224 objectOutput.writeUTF(uuid);
225 }
226
227 objectOutput.writeLong(threadId);
228 objectOutput.writeLong(groupId);
229 objectOutput.writeLong(companyId);
230 objectOutput.writeLong(userId);
231
232 if (userName == null) {
233 objectOutput.writeUTF(StringPool.BLANK);
234 }
235 else {
236 objectOutput.writeUTF(userName);
237 }
238
239 objectOutput.writeLong(createDate);
240 objectOutput.writeLong(modifiedDate);
241 objectOutput.writeLong(categoryId);
242 objectOutput.writeLong(rootMessageId);
243 objectOutput.writeLong(rootMessageUserId);
244 objectOutput.writeInt(messageCount);
245 objectOutput.writeInt(viewCount);
246 objectOutput.writeLong(lastPostByUserId);
247 objectOutput.writeLong(lastPostDate);
248 objectOutput.writeDouble(priority);
249 objectOutput.writeBoolean(question);
250 objectOutput.writeInt(status);
251 objectOutput.writeLong(statusByUserId);
252
253 if (statusByUserName == null) {
254 objectOutput.writeUTF(StringPool.BLANK);
255 }
256 else {
257 objectOutput.writeUTF(statusByUserName);
258 }
259
260 objectOutput.writeLong(statusDate);
261 }
262
263 public String uuid;
264 public long threadId;
265 public long groupId;
266 public long companyId;
267 public long userId;
268 public String userName;
269 public long createDate;
270 public long modifiedDate;
271 public long categoryId;
272 public long rootMessageId;
273 public long rootMessageUserId;
274 public int messageCount;
275 public int viewCount;
276 public long lastPostByUserId;
277 public long lastPostDate;
278 public double priority;
279 public boolean question;
280 public int status;
281 public long statusByUserId;
282 public String statusByUserName;
283 public long statusDate;
284 }