001
014
015 package com.liferay.portlet.asset.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.asset.model.AssetCategory;
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(31);
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("}");
102
103 return sb.toString();
104 }
105
106 @Override
107 public AssetCategory toEntityModel() {
108 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
109
110 if (uuid == null) {
111 assetCategoryImpl.setUuid(StringPool.BLANK);
112 }
113 else {
114 assetCategoryImpl.setUuid(uuid);
115 }
116
117 assetCategoryImpl.setCategoryId(categoryId);
118 assetCategoryImpl.setGroupId(groupId);
119 assetCategoryImpl.setCompanyId(companyId);
120 assetCategoryImpl.setUserId(userId);
121
122 if (userName == null) {
123 assetCategoryImpl.setUserName(StringPool.BLANK);
124 }
125 else {
126 assetCategoryImpl.setUserName(userName);
127 }
128
129 if (createDate == Long.MIN_VALUE) {
130 assetCategoryImpl.setCreateDate(null);
131 }
132 else {
133 assetCategoryImpl.setCreateDate(new Date(createDate));
134 }
135
136 if (modifiedDate == Long.MIN_VALUE) {
137 assetCategoryImpl.setModifiedDate(null);
138 }
139 else {
140 assetCategoryImpl.setModifiedDate(new Date(modifiedDate));
141 }
142
143 assetCategoryImpl.setParentCategoryId(parentCategoryId);
144 assetCategoryImpl.setLeftCategoryId(leftCategoryId);
145 assetCategoryImpl.setRightCategoryId(rightCategoryId);
146
147 if (name == null) {
148 assetCategoryImpl.setName(StringPool.BLANK);
149 }
150 else {
151 assetCategoryImpl.setName(name);
152 }
153
154 if (title == null) {
155 assetCategoryImpl.setTitle(StringPool.BLANK);
156 }
157 else {
158 assetCategoryImpl.setTitle(title);
159 }
160
161 if (description == null) {
162 assetCategoryImpl.setDescription(StringPool.BLANK);
163 }
164 else {
165 assetCategoryImpl.setDescription(description);
166 }
167
168 assetCategoryImpl.setVocabularyId(vocabularyId);
169
170 assetCategoryImpl.resetOriginalValues();
171
172 return assetCategoryImpl;
173 }
174
175 @Override
176 public void readExternal(ObjectInput objectInput) throws IOException {
177 uuid = objectInput.readUTF();
178 categoryId = objectInput.readLong();
179 groupId = objectInput.readLong();
180 companyId = objectInput.readLong();
181 userId = objectInput.readLong();
182 userName = objectInput.readUTF();
183 createDate = objectInput.readLong();
184 modifiedDate = objectInput.readLong();
185 parentCategoryId = objectInput.readLong();
186 leftCategoryId = objectInput.readLong();
187 rightCategoryId = objectInput.readLong();
188 name = objectInput.readUTF();
189 title = objectInput.readUTF();
190 description = objectInput.readUTF();
191 vocabularyId = objectInput.readLong();
192 }
193
194 @Override
195 public void writeExternal(ObjectOutput objectOutput)
196 throws IOException {
197 if (uuid == null) {
198 objectOutput.writeUTF(StringPool.BLANK);
199 }
200 else {
201 objectOutput.writeUTF(uuid);
202 }
203
204 objectOutput.writeLong(categoryId);
205 objectOutput.writeLong(groupId);
206 objectOutput.writeLong(companyId);
207 objectOutput.writeLong(userId);
208
209 if (userName == null) {
210 objectOutput.writeUTF(StringPool.BLANK);
211 }
212 else {
213 objectOutput.writeUTF(userName);
214 }
215
216 objectOutput.writeLong(createDate);
217 objectOutput.writeLong(modifiedDate);
218 objectOutput.writeLong(parentCategoryId);
219 objectOutput.writeLong(leftCategoryId);
220 objectOutput.writeLong(rightCategoryId);
221
222 if (name == null) {
223 objectOutput.writeUTF(StringPool.BLANK);
224 }
225 else {
226 objectOutput.writeUTF(name);
227 }
228
229 if (title == null) {
230 objectOutput.writeUTF(StringPool.BLANK);
231 }
232 else {
233 objectOutput.writeUTF(title);
234 }
235
236 if (description == null) {
237 objectOutput.writeUTF(StringPool.BLANK);
238 }
239 else {
240 objectOutput.writeUTF(description);
241 }
242
243 objectOutput.writeLong(vocabularyId);
244 }
245
246 public String uuid;
247 public long categoryId;
248 public long groupId;
249 public long companyId;
250 public long userId;
251 public String userName;
252 public long createDate;
253 public long modifiedDate;
254 public long parentCategoryId;
255 public long leftCategoryId;
256 public long rightCategoryId;
257 public String name;
258 public String title;
259 public String description;
260 public long vocabularyId;
261 }