001
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.MBCategory;
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
040 @ProviderType
041 public class MBCategoryCacheModel implements CacheModel<MBCategory>,
042 Externalizable {
043 @Override
044 public boolean equals(Object obj) {
045 if (this == obj) {
046 return true;
047 }
048
049 if (!(obj instanceof MBCategoryCacheModel)) {
050 return false;
051 }
052
053 MBCategoryCacheModel mbCategoryCacheModel = (MBCategoryCacheModel)obj;
054
055 if (categoryId == mbCategoryCacheModel.categoryId) {
056 return true;
057 }
058
059 return false;
060 }
061
062 @Override
063 public int hashCode() {
064 return HashUtil.hash(0, categoryId);
065 }
066
067 @Override
068 public String toString() {
069 StringBundler sb = new StringBundler(41);
070
071 sb.append("{uuid=");
072 sb.append(uuid);
073 sb.append(", categoryId=");
074 sb.append(categoryId);
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(", parentCategoryId=");
088 sb.append(parentCategoryId);
089 sb.append(", name=");
090 sb.append(name);
091 sb.append(", description=");
092 sb.append(description);
093 sb.append(", displayStyle=");
094 sb.append(displayStyle);
095 sb.append(", threadCount=");
096 sb.append(threadCount);
097 sb.append(", messageCount=");
098 sb.append(messageCount);
099 sb.append(", lastPostDate=");
100 sb.append(lastPostDate);
101 sb.append(", lastPublishDate=");
102 sb.append(lastPublishDate);
103 sb.append(", status=");
104 sb.append(status);
105 sb.append(", statusByUserId=");
106 sb.append(statusByUserId);
107 sb.append(", statusByUserName=");
108 sb.append(statusByUserName);
109 sb.append(", statusDate=");
110 sb.append(statusDate);
111 sb.append("}");
112
113 return sb.toString();
114 }
115
116 @Override
117 public MBCategory toEntityModel() {
118 MBCategoryImpl mbCategoryImpl = new MBCategoryImpl();
119
120 if (uuid == null) {
121 mbCategoryImpl.setUuid(StringPool.BLANK);
122 }
123 else {
124 mbCategoryImpl.setUuid(uuid);
125 }
126
127 mbCategoryImpl.setCategoryId(categoryId);
128 mbCategoryImpl.setGroupId(groupId);
129 mbCategoryImpl.setCompanyId(companyId);
130 mbCategoryImpl.setUserId(userId);
131
132 if (userName == null) {
133 mbCategoryImpl.setUserName(StringPool.BLANK);
134 }
135 else {
136 mbCategoryImpl.setUserName(userName);
137 }
138
139 if (createDate == Long.MIN_VALUE) {
140 mbCategoryImpl.setCreateDate(null);
141 }
142 else {
143 mbCategoryImpl.setCreateDate(new Date(createDate));
144 }
145
146 if (modifiedDate == Long.MIN_VALUE) {
147 mbCategoryImpl.setModifiedDate(null);
148 }
149 else {
150 mbCategoryImpl.setModifiedDate(new Date(modifiedDate));
151 }
152
153 mbCategoryImpl.setParentCategoryId(parentCategoryId);
154
155 if (name == null) {
156 mbCategoryImpl.setName(StringPool.BLANK);
157 }
158 else {
159 mbCategoryImpl.setName(name);
160 }
161
162 if (description == null) {
163 mbCategoryImpl.setDescription(StringPool.BLANK);
164 }
165 else {
166 mbCategoryImpl.setDescription(description);
167 }
168
169 if (displayStyle == null) {
170 mbCategoryImpl.setDisplayStyle(StringPool.BLANK);
171 }
172 else {
173 mbCategoryImpl.setDisplayStyle(displayStyle);
174 }
175
176 mbCategoryImpl.setThreadCount(threadCount);
177 mbCategoryImpl.setMessageCount(messageCount);
178
179 if (lastPostDate == Long.MIN_VALUE) {
180 mbCategoryImpl.setLastPostDate(null);
181 }
182 else {
183 mbCategoryImpl.setLastPostDate(new Date(lastPostDate));
184 }
185
186 if (lastPublishDate == Long.MIN_VALUE) {
187 mbCategoryImpl.setLastPublishDate(null);
188 }
189 else {
190 mbCategoryImpl.setLastPublishDate(new Date(lastPublishDate));
191 }
192
193 mbCategoryImpl.setStatus(status);
194 mbCategoryImpl.setStatusByUserId(statusByUserId);
195
196 if (statusByUserName == null) {
197 mbCategoryImpl.setStatusByUserName(StringPool.BLANK);
198 }
199 else {
200 mbCategoryImpl.setStatusByUserName(statusByUserName);
201 }
202
203 if (statusDate == Long.MIN_VALUE) {
204 mbCategoryImpl.setStatusDate(null);
205 }
206 else {
207 mbCategoryImpl.setStatusDate(new Date(statusDate));
208 }
209
210 mbCategoryImpl.resetOriginalValues();
211
212 return mbCategoryImpl;
213 }
214
215 @Override
216 public void readExternal(ObjectInput objectInput) throws IOException {
217 uuid = objectInput.readUTF();
218
219 categoryId = objectInput.readLong();
220
221 groupId = objectInput.readLong();
222
223 companyId = objectInput.readLong();
224
225 userId = objectInput.readLong();
226 userName = objectInput.readUTF();
227 createDate = objectInput.readLong();
228 modifiedDate = objectInput.readLong();
229
230 parentCategoryId = objectInput.readLong();
231 name = objectInput.readUTF();
232 description = objectInput.readUTF();
233 displayStyle = objectInput.readUTF();
234
235 threadCount = objectInput.readInt();
236
237 messageCount = objectInput.readInt();
238 lastPostDate = objectInput.readLong();
239 lastPublishDate = objectInput.readLong();
240
241 status = objectInput.readInt();
242
243 statusByUserId = objectInput.readLong();
244 statusByUserName = objectInput.readUTF();
245 statusDate = objectInput.readLong();
246 }
247
248 @Override
249 public void writeExternal(ObjectOutput objectOutput)
250 throws IOException {
251 if (uuid == null) {
252 objectOutput.writeUTF(StringPool.BLANK);
253 }
254 else {
255 objectOutput.writeUTF(uuid);
256 }
257
258 objectOutput.writeLong(categoryId);
259
260 objectOutput.writeLong(groupId);
261
262 objectOutput.writeLong(companyId);
263
264 objectOutput.writeLong(userId);
265
266 if (userName == null) {
267 objectOutput.writeUTF(StringPool.BLANK);
268 }
269 else {
270 objectOutput.writeUTF(userName);
271 }
272
273 objectOutput.writeLong(createDate);
274 objectOutput.writeLong(modifiedDate);
275
276 objectOutput.writeLong(parentCategoryId);
277
278 if (name == null) {
279 objectOutput.writeUTF(StringPool.BLANK);
280 }
281 else {
282 objectOutput.writeUTF(name);
283 }
284
285 if (description == null) {
286 objectOutput.writeUTF(StringPool.BLANK);
287 }
288 else {
289 objectOutput.writeUTF(description);
290 }
291
292 if (displayStyle == null) {
293 objectOutput.writeUTF(StringPool.BLANK);
294 }
295 else {
296 objectOutput.writeUTF(displayStyle);
297 }
298
299 objectOutput.writeInt(threadCount);
300
301 objectOutput.writeInt(messageCount);
302 objectOutput.writeLong(lastPostDate);
303 objectOutput.writeLong(lastPublishDate);
304
305 objectOutput.writeInt(status);
306
307 objectOutput.writeLong(statusByUserId);
308
309 if (statusByUserName == null) {
310 objectOutput.writeUTF(StringPool.BLANK);
311 }
312 else {
313 objectOutput.writeUTF(statusByUserName);
314 }
315
316 objectOutput.writeLong(statusDate);
317 }
318
319 public String uuid;
320 public long categoryId;
321 public long groupId;
322 public long companyId;
323 public long userId;
324 public String userName;
325 public long createDate;
326 public long modifiedDate;
327 public long parentCategoryId;
328 public String name;
329 public String description;
330 public String displayStyle;
331 public int threadCount;
332 public int messageCount;
333 public long lastPostDate;
334 public long lastPublishDate;
335 public int status;
336 public long statusByUserId;
337 public String statusByUserName;
338 public long statusDate;
339 }