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.Image;
024 import com.liferay.portal.model.MVCCModel;
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 ImageCacheModel implements CacheModel<Image>, Externalizable,
042 MVCCModel {
043 @Override
044 public boolean equals(Object obj) {
045 if (this == obj) {
046 return true;
047 }
048
049 if (!(obj instanceof ImageCacheModel)) {
050 return false;
051 }
052
053 ImageCacheModel imageCacheModel = (ImageCacheModel)obj;
054
055 if ((imageId == imageCacheModel.imageId) &&
056 (mvccVersion == imageCacheModel.mvccVersion)) {
057 return true;
058 }
059
060 return false;
061 }
062
063 @Override
064 public int hashCode() {
065 int hashCode = HashUtil.hash(0, imageId);
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(17);
083
084 sb.append("{mvccVersion=");
085 sb.append(mvccVersion);
086 sb.append(", imageId=");
087 sb.append(imageId);
088 sb.append(", companyId=");
089 sb.append(companyId);
090 sb.append(", modifiedDate=");
091 sb.append(modifiedDate);
092 sb.append(", type=");
093 sb.append(type);
094 sb.append(", height=");
095 sb.append(height);
096 sb.append(", width=");
097 sb.append(width);
098 sb.append(", size=");
099 sb.append(size);
100 sb.append("}");
101
102 return sb.toString();
103 }
104
105 @Override
106 public Image toEntityModel() {
107 ImageImpl imageImpl = new ImageImpl();
108
109 imageImpl.setMvccVersion(mvccVersion);
110 imageImpl.setImageId(imageId);
111 imageImpl.setCompanyId(companyId);
112
113 if (modifiedDate == Long.MIN_VALUE) {
114 imageImpl.setModifiedDate(null);
115 }
116 else {
117 imageImpl.setModifiedDate(new Date(modifiedDate));
118 }
119
120 if (type == null) {
121 imageImpl.setType(StringPool.BLANK);
122 }
123 else {
124 imageImpl.setType(type);
125 }
126
127 imageImpl.setHeight(height);
128 imageImpl.setWidth(width);
129 imageImpl.setSize(size);
130
131 imageImpl.resetOriginalValues();
132
133 return imageImpl;
134 }
135
136 @Override
137 public void readExternal(ObjectInput objectInput) throws IOException {
138 mvccVersion = objectInput.readLong();
139 imageId = objectInput.readLong();
140 companyId = objectInput.readLong();
141 modifiedDate = objectInput.readLong();
142 type = objectInput.readUTF();
143 height = objectInput.readInt();
144 width = objectInput.readInt();
145 size = objectInput.readInt();
146 }
147
148 @Override
149 public void writeExternal(ObjectOutput objectOutput)
150 throws IOException {
151 objectOutput.writeLong(mvccVersion);
152 objectOutput.writeLong(imageId);
153 objectOutput.writeLong(companyId);
154 objectOutput.writeLong(modifiedDate);
155
156 if (type == null) {
157 objectOutput.writeUTF(StringPool.BLANK);
158 }
159 else {
160 objectOutput.writeUTF(type);
161 }
162
163 objectOutput.writeInt(height);
164 objectOutput.writeInt(width);
165 objectOutput.writeInt(size);
166 }
167
168 public long mvccVersion;
169 public long imageId;
170 public long companyId;
171 public long modifiedDate;
172 public String type;
173 public int height;
174 public int width;
175 public int size;
176 }