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.MBCategory;
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 categoryId = objectInput.readLong();
219 groupId = objectInput.readLong();
220 companyId = objectInput.readLong();
221 userId = objectInput.readLong();
222 userName = objectInput.readUTF();
223 createDate = objectInput.readLong();
224 modifiedDate = objectInput.readLong();
225 parentCategoryId = objectInput.readLong();
226 name = objectInput.readUTF();
227 description = objectInput.readUTF();
228 displayStyle = objectInput.readUTF();
229 threadCount = objectInput.readInt();
230 messageCount = objectInput.readInt();
231 lastPostDate = objectInput.readLong();
232 lastPublishDate = objectInput.readLong();
233 status = objectInput.readInt();
234 statusByUserId = objectInput.readLong();
235 statusByUserName = objectInput.readUTF();
236 statusDate = objectInput.readLong();
237 }
238
239 @Override
240 public void writeExternal(ObjectOutput objectOutput)
241 throws IOException {
242 if (uuid == null) {
243 objectOutput.writeUTF(StringPool.BLANK);
244 }
245 else {
246 objectOutput.writeUTF(uuid);
247 }
248
249 objectOutput.writeLong(categoryId);
250 objectOutput.writeLong(groupId);
251 objectOutput.writeLong(companyId);
252 objectOutput.writeLong(userId);
253
254 if (userName == null) {
255 objectOutput.writeUTF(StringPool.BLANK);
256 }
257 else {
258 objectOutput.writeUTF(userName);
259 }
260
261 objectOutput.writeLong(createDate);
262 objectOutput.writeLong(modifiedDate);
263 objectOutput.writeLong(parentCategoryId);
264
265 if (name == null) {
266 objectOutput.writeUTF(StringPool.BLANK);
267 }
268 else {
269 objectOutput.writeUTF(name);
270 }
271
272 if (description == null) {
273 objectOutput.writeUTF(StringPool.BLANK);
274 }
275 else {
276 objectOutput.writeUTF(description);
277 }
278
279 if (displayStyle == null) {
280 objectOutput.writeUTF(StringPool.BLANK);
281 }
282 else {
283 objectOutput.writeUTF(displayStyle);
284 }
285
286 objectOutput.writeInt(threadCount);
287 objectOutput.writeInt(messageCount);
288 objectOutput.writeLong(lastPostDate);
289 objectOutput.writeLong(lastPublishDate);
290 objectOutput.writeInt(status);
291 objectOutput.writeLong(statusByUserId);
292
293 if (statusByUserName == null) {
294 objectOutput.writeUTF(StringPool.BLANK);
295 }
296 else {
297 objectOutput.writeUTF(statusByUserName);
298 }
299
300 objectOutput.writeLong(statusDate);
301 }
302
303 public String uuid;
304 public long categoryId;
305 public long groupId;
306 public long companyId;
307 public long userId;
308 public String userName;
309 public long createDate;
310 public long modifiedDate;
311 public long parentCategoryId;
312 public String name;
313 public String description;
314 public String displayStyle;
315 public int threadCount;
316 public int messageCount;
317 public long lastPostDate;
318 public long lastPublishDate;
319 public int status;
320 public long statusByUserId;
321 public String statusByUserName;
322 public long statusDate;
323 }