001
014
015 package com.liferay.portlet.asset.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.asset.kernel.model.AssetCategory;
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 AssetCategoryCacheModel implements CacheModel<AssetCategory>,
042 Externalizable {
043 @Override
044 public boolean equals(Object obj) {
045 if (this == obj) {
046 return true;
047 }
048
049 if (!(obj instanceof AssetCategoryCacheModel)) {
050 return false;
051 }
052
053 AssetCategoryCacheModel assetCategoryCacheModel = (AssetCategoryCacheModel)obj;
054
055 if (categoryId == assetCategoryCacheModel.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(33);
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(", leftCategoryId=");
090 sb.append(leftCategoryId);
091 sb.append(", rightCategoryId=");
092 sb.append(rightCategoryId);
093 sb.append(", name=");
094 sb.append(name);
095 sb.append(", title=");
096 sb.append(title);
097 sb.append(", description=");
098 sb.append(description);
099 sb.append(", vocabularyId=");
100 sb.append(vocabularyId);
101 sb.append(", lastPublishDate=");
102 sb.append(lastPublishDate);
103 sb.append("}");
104
105 return sb.toString();
106 }
107
108 @Override
109 public AssetCategory toEntityModel() {
110 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
111
112 if (uuid == null) {
113 assetCategoryImpl.setUuid(StringPool.BLANK);
114 }
115 else {
116 assetCategoryImpl.setUuid(uuid);
117 }
118
119 assetCategoryImpl.setCategoryId(categoryId);
120 assetCategoryImpl.setGroupId(groupId);
121 assetCategoryImpl.setCompanyId(companyId);
122 assetCategoryImpl.setUserId(userId);
123
124 if (userName == null) {
125 assetCategoryImpl.setUserName(StringPool.BLANK);
126 }
127 else {
128 assetCategoryImpl.setUserName(userName);
129 }
130
131 if (createDate == Long.MIN_VALUE) {
132 assetCategoryImpl.setCreateDate(null);
133 }
134 else {
135 assetCategoryImpl.setCreateDate(new Date(createDate));
136 }
137
138 if (modifiedDate == Long.MIN_VALUE) {
139 assetCategoryImpl.setModifiedDate(null);
140 }
141 else {
142 assetCategoryImpl.setModifiedDate(new Date(modifiedDate));
143 }
144
145 assetCategoryImpl.setParentCategoryId(parentCategoryId);
146 assetCategoryImpl.setLeftCategoryId(leftCategoryId);
147 assetCategoryImpl.setRightCategoryId(rightCategoryId);
148
149 if (name == null) {
150 assetCategoryImpl.setName(StringPool.BLANK);
151 }
152 else {
153 assetCategoryImpl.setName(name);
154 }
155
156 if (title == null) {
157 assetCategoryImpl.setTitle(StringPool.BLANK);
158 }
159 else {
160 assetCategoryImpl.setTitle(title);
161 }
162
163 if (description == null) {
164 assetCategoryImpl.setDescription(StringPool.BLANK);
165 }
166 else {
167 assetCategoryImpl.setDescription(description);
168 }
169
170 assetCategoryImpl.setVocabularyId(vocabularyId);
171
172 if (lastPublishDate == Long.MIN_VALUE) {
173 assetCategoryImpl.setLastPublishDate(null);
174 }
175 else {
176 assetCategoryImpl.setLastPublishDate(new Date(lastPublishDate));
177 }
178
179 assetCategoryImpl.resetOriginalValues();
180
181 return assetCategoryImpl;
182 }
183
184 @Override
185 public void readExternal(ObjectInput objectInput) throws IOException {
186 uuid = objectInput.readUTF();
187
188 categoryId = objectInput.readLong();
189
190 groupId = objectInput.readLong();
191
192 companyId = objectInput.readLong();
193
194 userId = objectInput.readLong();
195 userName = objectInput.readUTF();
196 createDate = objectInput.readLong();
197 modifiedDate = objectInput.readLong();
198
199 parentCategoryId = objectInput.readLong();
200
201 leftCategoryId = objectInput.readLong();
202
203 rightCategoryId = objectInput.readLong();
204 name = objectInput.readUTF();
205 title = objectInput.readUTF();
206 description = objectInput.readUTF();
207
208 vocabularyId = objectInput.readLong();
209 lastPublishDate = objectInput.readLong();
210 }
211
212 @Override
213 public void writeExternal(ObjectOutput objectOutput)
214 throws IOException {
215 if (uuid == null) {
216 objectOutput.writeUTF(StringPool.BLANK);
217 }
218 else {
219 objectOutput.writeUTF(uuid);
220 }
221
222 objectOutput.writeLong(categoryId);
223
224 objectOutput.writeLong(groupId);
225
226 objectOutput.writeLong(companyId);
227
228 objectOutput.writeLong(userId);
229
230 if (userName == null) {
231 objectOutput.writeUTF(StringPool.BLANK);
232 }
233 else {
234 objectOutput.writeUTF(userName);
235 }
236
237 objectOutput.writeLong(createDate);
238 objectOutput.writeLong(modifiedDate);
239
240 objectOutput.writeLong(parentCategoryId);
241
242 objectOutput.writeLong(leftCategoryId);
243
244 objectOutput.writeLong(rightCategoryId);
245
246 if (name == null) {
247 objectOutput.writeUTF(StringPool.BLANK);
248 }
249 else {
250 objectOutput.writeUTF(name);
251 }
252
253 if (title == null) {
254 objectOutput.writeUTF(StringPool.BLANK);
255 }
256 else {
257 objectOutput.writeUTF(title);
258 }
259
260 if (description == null) {
261 objectOutput.writeUTF(StringPool.BLANK);
262 }
263 else {
264 objectOutput.writeUTF(description);
265 }
266
267 objectOutput.writeLong(vocabularyId);
268 objectOutput.writeLong(lastPublishDate);
269 }
270
271 public String uuid;
272 public long categoryId;
273 public long groupId;
274 public long companyId;
275 public long userId;
276 public String userName;
277 public long createDate;
278 public long modifiedDate;
279 public long parentCategoryId;
280 public long leftCategoryId;
281 public long rightCategoryId;
282 public String name;
283 public String title;
284 public String description;
285 public long vocabularyId;
286 public long lastPublishDate;
287 }