001
014
015 package com.liferay.portlet.ratings.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.model.CacheModel;
020 import com.liferay.portal.kernel.util.HashUtil;
021 import com.liferay.portal.kernel.util.StringBundler;
022 import com.liferay.portal.kernel.util.StringPool;
023
024 import com.liferay.ratings.kernel.model.RatingsEntry;
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 RatingsEntryCacheModel implements CacheModel<RatingsEntry>,
042 Externalizable {
043 @Override
044 public boolean equals(Object obj) {
045 if (this == obj) {
046 return true;
047 }
048
049 if (!(obj instanceof RatingsEntryCacheModel)) {
050 return false;
051 }
052
053 RatingsEntryCacheModel ratingsEntryCacheModel = (RatingsEntryCacheModel)obj;
054
055 if (entryId == ratingsEntryCacheModel.entryId) {
056 return true;
057 }
058
059 return false;
060 }
061
062 @Override
063 public int hashCode() {
064 return HashUtil.hash(0, entryId);
065 }
066
067 @Override
068 public String toString() {
069 StringBundler sb = new StringBundler(21);
070
071 sb.append("{uuid=");
072 sb.append(uuid);
073 sb.append(", entryId=");
074 sb.append(entryId);
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(", classNameId=");
086 sb.append(classNameId);
087 sb.append(", classPK=");
088 sb.append(classPK);
089 sb.append(", score=");
090 sb.append(score);
091 sb.append("}");
092
093 return sb.toString();
094 }
095
096 @Override
097 public RatingsEntry toEntityModel() {
098 RatingsEntryImpl ratingsEntryImpl = new RatingsEntryImpl();
099
100 if (uuid == null) {
101 ratingsEntryImpl.setUuid(StringPool.BLANK);
102 }
103 else {
104 ratingsEntryImpl.setUuid(uuid);
105 }
106
107 ratingsEntryImpl.setEntryId(entryId);
108 ratingsEntryImpl.setCompanyId(companyId);
109 ratingsEntryImpl.setUserId(userId);
110
111 if (userName == null) {
112 ratingsEntryImpl.setUserName(StringPool.BLANK);
113 }
114 else {
115 ratingsEntryImpl.setUserName(userName);
116 }
117
118 if (createDate == Long.MIN_VALUE) {
119 ratingsEntryImpl.setCreateDate(null);
120 }
121 else {
122 ratingsEntryImpl.setCreateDate(new Date(createDate));
123 }
124
125 if (modifiedDate == Long.MIN_VALUE) {
126 ratingsEntryImpl.setModifiedDate(null);
127 }
128 else {
129 ratingsEntryImpl.setModifiedDate(new Date(modifiedDate));
130 }
131
132 ratingsEntryImpl.setClassNameId(classNameId);
133 ratingsEntryImpl.setClassPK(classPK);
134 ratingsEntryImpl.setScore(score);
135
136 ratingsEntryImpl.resetOriginalValues();
137
138 return ratingsEntryImpl;
139 }
140
141 @Override
142 public void readExternal(ObjectInput objectInput) throws IOException {
143 uuid = objectInput.readUTF();
144
145 entryId = objectInput.readLong();
146
147 companyId = objectInput.readLong();
148
149 userId = objectInput.readLong();
150 userName = objectInput.readUTF();
151 createDate = objectInput.readLong();
152 modifiedDate = objectInput.readLong();
153
154 classNameId = objectInput.readLong();
155
156 classPK = objectInput.readLong();
157
158 score = objectInput.readDouble();
159 }
160
161 @Override
162 public void writeExternal(ObjectOutput objectOutput)
163 throws IOException {
164 if (uuid == null) {
165 objectOutput.writeUTF(StringPool.BLANK);
166 }
167 else {
168 objectOutput.writeUTF(uuid);
169 }
170
171 objectOutput.writeLong(entryId);
172
173 objectOutput.writeLong(companyId);
174
175 objectOutput.writeLong(userId);
176
177 if (userName == null) {
178 objectOutput.writeUTF(StringPool.BLANK);
179 }
180 else {
181 objectOutput.writeUTF(userName);
182 }
183
184 objectOutput.writeLong(createDate);
185 objectOutput.writeLong(modifiedDate);
186
187 objectOutput.writeLong(classNameId);
188
189 objectOutput.writeLong(classPK);
190
191 objectOutput.writeDouble(score);
192 }
193
194 public String uuid;
195 public long entryId;
196 public long companyId;
197 public long userId;
198 public String userName;
199 public long createDate;
200 public long modifiedDate;
201 public long classNameId;
202 public long classPK;
203 public double score;
204 }