001
014
015 package com.liferay.portlet.dynamicdatamapping.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.dynamicdatamapping.model.DDMContent;
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 DDMContentCacheModel implements CacheModel<DDMContent>,
042 Externalizable {
043 @Override
044 public boolean equals(Object obj) {
045 if (this == obj) {
046 return true;
047 }
048
049 if (!(obj instanceof DDMContentCacheModel)) {
050 return false;
051 }
052
053 DDMContentCacheModel ddmContentCacheModel = (DDMContentCacheModel)obj;
054
055 if (contentId == ddmContentCacheModel.contentId) {
056 return true;
057 }
058
059 return false;
060 }
061
062 @Override
063 public int hashCode() {
064 return HashUtil.hash(0, contentId);
065 }
066
067 @Override
068 public String toString() {
069 StringBundler sb = new StringBundler(23);
070
071 sb.append("{uuid=");
072 sb.append(uuid);
073 sb.append(", contentId=");
074 sb.append(contentId);
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(", name=");
088 sb.append(name);
089 sb.append(", description=");
090 sb.append(description);
091 sb.append(", data=");
092 sb.append(data);
093 sb.append("}");
094
095 return sb.toString();
096 }
097
098 @Override
099 public DDMContent toEntityModel() {
100 DDMContentImpl ddmContentImpl = new DDMContentImpl();
101
102 if (uuid == null) {
103 ddmContentImpl.setUuid(StringPool.BLANK);
104 }
105 else {
106 ddmContentImpl.setUuid(uuid);
107 }
108
109 ddmContentImpl.setContentId(contentId);
110 ddmContentImpl.setGroupId(groupId);
111 ddmContentImpl.setCompanyId(companyId);
112 ddmContentImpl.setUserId(userId);
113
114 if (userName == null) {
115 ddmContentImpl.setUserName(StringPool.BLANK);
116 }
117 else {
118 ddmContentImpl.setUserName(userName);
119 }
120
121 if (createDate == Long.MIN_VALUE) {
122 ddmContentImpl.setCreateDate(null);
123 }
124 else {
125 ddmContentImpl.setCreateDate(new Date(createDate));
126 }
127
128 if (modifiedDate == Long.MIN_VALUE) {
129 ddmContentImpl.setModifiedDate(null);
130 }
131 else {
132 ddmContentImpl.setModifiedDate(new Date(modifiedDate));
133 }
134
135 if (name == null) {
136 ddmContentImpl.setName(StringPool.BLANK);
137 }
138 else {
139 ddmContentImpl.setName(name);
140 }
141
142 if (description == null) {
143 ddmContentImpl.setDescription(StringPool.BLANK);
144 }
145 else {
146 ddmContentImpl.setDescription(description);
147 }
148
149 if (data == null) {
150 ddmContentImpl.setData(StringPool.BLANK);
151 }
152 else {
153 ddmContentImpl.setData(data);
154 }
155
156 ddmContentImpl.resetOriginalValues();
157
158 return ddmContentImpl;
159 }
160
161 @Override
162 public void readExternal(ObjectInput objectInput) throws IOException {
163 uuid = objectInput.readUTF();
164 contentId = objectInput.readLong();
165 groupId = objectInput.readLong();
166 companyId = objectInput.readLong();
167 userId = objectInput.readLong();
168 userName = objectInput.readUTF();
169 createDate = objectInput.readLong();
170 modifiedDate = objectInput.readLong();
171 name = objectInput.readUTF();
172 description = objectInput.readUTF();
173 data = objectInput.readUTF();
174 }
175
176 @Override
177 public void writeExternal(ObjectOutput objectOutput)
178 throws IOException {
179 if (uuid == null) {
180 objectOutput.writeUTF(StringPool.BLANK);
181 }
182 else {
183 objectOutput.writeUTF(uuid);
184 }
185
186 objectOutput.writeLong(contentId);
187 objectOutput.writeLong(groupId);
188 objectOutput.writeLong(companyId);
189 objectOutput.writeLong(userId);
190
191 if (userName == null) {
192 objectOutput.writeUTF(StringPool.BLANK);
193 }
194 else {
195 objectOutput.writeUTF(userName);
196 }
197
198 objectOutput.writeLong(createDate);
199 objectOutput.writeLong(modifiedDate);
200
201 if (name == null) {
202 objectOutput.writeUTF(StringPool.BLANK);
203 }
204 else {
205 objectOutput.writeUTF(name);
206 }
207
208 if (description == null) {
209 objectOutput.writeUTF(StringPool.BLANK);
210 }
211 else {
212 objectOutput.writeUTF(description);
213 }
214
215 if (data == null) {
216 objectOutput.writeUTF(StringPool.BLANK);
217 }
218 else {
219 objectOutput.writeUTF(data);
220 }
221 }
222
223 public String uuid;
224 public long contentId;
225 public long groupId;
226 public long companyId;
227 public long userId;
228 public String userName;
229 public long createDate;
230 public long modifiedDate;
231 public String name;
232 public String description;
233 public String data;
234 }