001
014
015 package com.liferay.portlet.shopping.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.shopping.model.ShoppingCategory;
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 ShoppingCategoryCacheModel implements CacheModel<ShoppingCategory>,
042 Externalizable {
043 @Override
044 public boolean equals(Object obj) {
045 if (this == obj) {
046 return true;
047 }
048
049 if (!(obj instanceof ShoppingCategoryCacheModel)) {
050 return false;
051 }
052
053 ShoppingCategoryCacheModel shoppingCategoryCacheModel = (ShoppingCategoryCacheModel)obj;
054
055 if (categoryId == shoppingCategoryCacheModel.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(21);
070
071 sb.append("{categoryId=");
072 sb.append(categoryId);
073 sb.append(", groupId=");
074 sb.append(groupId);
075 sb.append(", companyId=");
076 sb.append(companyId);
077 sb.append(", userId=");
078 sb.append(userId);
079 sb.append(", userName=");
080 sb.append(userName);
081 sb.append(", createDate=");
082 sb.append(createDate);
083 sb.append(", modifiedDate=");
084 sb.append(modifiedDate);
085 sb.append(", parentCategoryId=");
086 sb.append(parentCategoryId);
087 sb.append(", name=");
088 sb.append(name);
089 sb.append(", description=");
090 sb.append(description);
091 sb.append("}");
092
093 return sb.toString();
094 }
095
096 @Override
097 public ShoppingCategory toEntityModel() {
098 ShoppingCategoryImpl shoppingCategoryImpl = new ShoppingCategoryImpl();
099
100 shoppingCategoryImpl.setCategoryId(categoryId);
101 shoppingCategoryImpl.setGroupId(groupId);
102 shoppingCategoryImpl.setCompanyId(companyId);
103 shoppingCategoryImpl.setUserId(userId);
104
105 if (userName == null) {
106 shoppingCategoryImpl.setUserName(StringPool.BLANK);
107 }
108 else {
109 shoppingCategoryImpl.setUserName(userName);
110 }
111
112 if (createDate == Long.MIN_VALUE) {
113 shoppingCategoryImpl.setCreateDate(null);
114 }
115 else {
116 shoppingCategoryImpl.setCreateDate(new Date(createDate));
117 }
118
119 if (modifiedDate == Long.MIN_VALUE) {
120 shoppingCategoryImpl.setModifiedDate(null);
121 }
122 else {
123 shoppingCategoryImpl.setModifiedDate(new Date(modifiedDate));
124 }
125
126 shoppingCategoryImpl.setParentCategoryId(parentCategoryId);
127
128 if (name == null) {
129 shoppingCategoryImpl.setName(StringPool.BLANK);
130 }
131 else {
132 shoppingCategoryImpl.setName(name);
133 }
134
135 if (description == null) {
136 shoppingCategoryImpl.setDescription(StringPool.BLANK);
137 }
138 else {
139 shoppingCategoryImpl.setDescription(description);
140 }
141
142 shoppingCategoryImpl.resetOriginalValues();
143
144 return shoppingCategoryImpl;
145 }
146
147 @Override
148 public void readExternal(ObjectInput objectInput) throws IOException {
149 categoryId = objectInput.readLong();
150 groupId = objectInput.readLong();
151 companyId = objectInput.readLong();
152 userId = objectInput.readLong();
153 userName = objectInput.readUTF();
154 createDate = objectInput.readLong();
155 modifiedDate = objectInput.readLong();
156 parentCategoryId = objectInput.readLong();
157 name = objectInput.readUTF();
158 description = objectInput.readUTF();
159 }
160
161 @Override
162 public void writeExternal(ObjectOutput objectOutput)
163 throws IOException {
164 objectOutput.writeLong(categoryId);
165 objectOutput.writeLong(groupId);
166 objectOutput.writeLong(companyId);
167 objectOutput.writeLong(userId);
168
169 if (userName == null) {
170 objectOutput.writeUTF(StringPool.BLANK);
171 }
172 else {
173 objectOutput.writeUTF(userName);
174 }
175
176 objectOutput.writeLong(createDate);
177 objectOutput.writeLong(modifiedDate);
178 objectOutput.writeLong(parentCategoryId);
179
180 if (name == null) {
181 objectOutput.writeUTF(StringPool.BLANK);
182 }
183 else {
184 objectOutput.writeUTF(name);
185 }
186
187 if (description == null) {
188 objectOutput.writeUTF(StringPool.BLANK);
189 }
190 else {
191 objectOutput.writeUTF(description);
192 }
193 }
194
195 public long categoryId;
196 public long groupId;
197 public long companyId;
198 public long userId;
199 public String userName;
200 public long createDate;
201 public long modifiedDate;
202 public long parentCategoryId;
203 public String name;
204 public String description;
205 }