001
014
015 package com.liferay.portal.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 import com.liferay.portal.model.MVCCModel;
024 import com.liferay.portal.model.Ticket;
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 TicketCacheModel implements CacheModel<Ticket>, Externalizable,
042 MVCCModel {
043 @Override
044 public boolean equals(Object obj) {
045 if (this == obj) {
046 return true;
047 }
048
049 if (!(obj instanceof TicketCacheModel)) {
050 return false;
051 }
052
053 TicketCacheModel ticketCacheModel = (TicketCacheModel)obj;
054
055 if ((ticketId == ticketCacheModel.ticketId) &&
056 (mvccVersion == ticketCacheModel.mvccVersion)) {
057 return true;
058 }
059
060 return false;
061 }
062
063 @Override
064 public int hashCode() {
065 int hashCode = HashUtil.hash(0, ticketId);
066
067 return HashUtil.hash(hashCode, mvccVersion);
068 }
069
070 @Override
071 public long getMvccVersion() {
072 return mvccVersion;
073 }
074
075 @Override
076 public void setMvccVersion(long mvccVersion) {
077 this.mvccVersion = mvccVersion;
078 }
079
080 @Override
081 public String toString() {
082 StringBundler sb = new StringBundler(21);
083
084 sb.append("{mvccVersion=");
085 sb.append(mvccVersion);
086 sb.append(", ticketId=");
087 sb.append(ticketId);
088 sb.append(", companyId=");
089 sb.append(companyId);
090 sb.append(", createDate=");
091 sb.append(createDate);
092 sb.append(", classNameId=");
093 sb.append(classNameId);
094 sb.append(", classPK=");
095 sb.append(classPK);
096 sb.append(", key=");
097 sb.append(key);
098 sb.append(", type=");
099 sb.append(type);
100 sb.append(", extraInfo=");
101 sb.append(extraInfo);
102 sb.append(", expirationDate=");
103 sb.append(expirationDate);
104 sb.append("}");
105
106 return sb.toString();
107 }
108
109 @Override
110 public Ticket toEntityModel() {
111 TicketImpl ticketImpl = new TicketImpl();
112
113 ticketImpl.setMvccVersion(mvccVersion);
114 ticketImpl.setTicketId(ticketId);
115 ticketImpl.setCompanyId(companyId);
116
117 if (createDate == Long.MIN_VALUE) {
118 ticketImpl.setCreateDate(null);
119 }
120 else {
121 ticketImpl.setCreateDate(new Date(createDate));
122 }
123
124 ticketImpl.setClassNameId(classNameId);
125 ticketImpl.setClassPK(classPK);
126
127 if (key == null) {
128 ticketImpl.setKey(StringPool.BLANK);
129 }
130 else {
131 ticketImpl.setKey(key);
132 }
133
134 ticketImpl.setType(type);
135
136 if (extraInfo == null) {
137 ticketImpl.setExtraInfo(StringPool.BLANK);
138 }
139 else {
140 ticketImpl.setExtraInfo(extraInfo);
141 }
142
143 if (expirationDate == Long.MIN_VALUE) {
144 ticketImpl.setExpirationDate(null);
145 }
146 else {
147 ticketImpl.setExpirationDate(new Date(expirationDate));
148 }
149
150 ticketImpl.resetOriginalValues();
151
152 return ticketImpl;
153 }
154
155 @Override
156 public void readExternal(ObjectInput objectInput) throws IOException {
157 mvccVersion = objectInput.readLong();
158 ticketId = objectInput.readLong();
159 companyId = objectInput.readLong();
160 createDate = objectInput.readLong();
161 classNameId = objectInput.readLong();
162 classPK = objectInput.readLong();
163 key = objectInput.readUTF();
164 type = objectInput.readInt();
165 extraInfo = objectInput.readUTF();
166 expirationDate = objectInput.readLong();
167 }
168
169 @Override
170 public void writeExternal(ObjectOutput objectOutput)
171 throws IOException {
172 objectOutput.writeLong(mvccVersion);
173 objectOutput.writeLong(ticketId);
174 objectOutput.writeLong(companyId);
175 objectOutput.writeLong(createDate);
176 objectOutput.writeLong(classNameId);
177 objectOutput.writeLong(classPK);
178
179 if (key == null) {
180 objectOutput.writeUTF(StringPool.BLANK);
181 }
182 else {
183 objectOutput.writeUTF(key);
184 }
185
186 objectOutput.writeInt(type);
187
188 if (extraInfo == null) {
189 objectOutput.writeUTF(StringPool.BLANK);
190 }
191 else {
192 objectOutput.writeUTF(extraInfo);
193 }
194
195 objectOutput.writeLong(expirationDate);
196 }
197
198 public long mvccVersion;
199 public long ticketId;
200 public long companyId;
201 public long createDate;
202 public long classNameId;
203 public long classPK;
204 public String key;
205 public int type;
206 public String extraInfo;
207 public long expirationDate;
208 }