001
014
015 package com.liferay.portlet.asset.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.asset.kernel.model.AssetLink;
020
021 import com.liferay.portal.kernel.model.CacheModel;
022 import com.liferay.portal.kernel.util.HashUtil;
023 import com.liferay.portal.kernel.util.StringBundler;
024 import com.liferay.portal.kernel.util.StringPool;
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 AssetLinkCacheModel implements CacheModel<AssetLink>,
042 Externalizable {
043 @Override
044 public boolean equals(Object obj) {
045 if (this == obj) {
046 return true;
047 }
048
049 if (!(obj instanceof AssetLinkCacheModel)) {
050 return false;
051 }
052
053 AssetLinkCacheModel assetLinkCacheModel = (AssetLinkCacheModel)obj;
054
055 if (linkId == assetLinkCacheModel.linkId) {
056 return true;
057 }
058
059 return false;
060 }
061
062 @Override
063 public int hashCode() {
064 return HashUtil.hash(0, linkId);
065 }
066
067 @Override
068 public String toString() {
069 StringBundler sb = new StringBundler(19);
070
071 sb.append("{linkId=");
072 sb.append(linkId);
073 sb.append(", companyId=");
074 sb.append(companyId);
075 sb.append(", userId=");
076 sb.append(userId);
077 sb.append(", userName=");
078 sb.append(userName);
079 sb.append(", createDate=");
080 sb.append(createDate);
081 sb.append(", entryId1=");
082 sb.append(entryId1);
083 sb.append(", entryId2=");
084 sb.append(entryId2);
085 sb.append(", type=");
086 sb.append(type);
087 sb.append(", weight=");
088 sb.append(weight);
089 sb.append("}");
090
091 return sb.toString();
092 }
093
094 @Override
095 public AssetLink toEntityModel() {
096 AssetLinkImpl assetLinkImpl = new AssetLinkImpl();
097
098 assetLinkImpl.setLinkId(linkId);
099 assetLinkImpl.setCompanyId(companyId);
100 assetLinkImpl.setUserId(userId);
101
102 if (userName == null) {
103 assetLinkImpl.setUserName(StringPool.BLANK);
104 }
105 else {
106 assetLinkImpl.setUserName(userName);
107 }
108
109 if (createDate == Long.MIN_VALUE) {
110 assetLinkImpl.setCreateDate(null);
111 }
112 else {
113 assetLinkImpl.setCreateDate(new Date(createDate));
114 }
115
116 assetLinkImpl.setEntryId1(entryId1);
117 assetLinkImpl.setEntryId2(entryId2);
118 assetLinkImpl.setType(type);
119 assetLinkImpl.setWeight(weight);
120
121 assetLinkImpl.resetOriginalValues();
122
123 return assetLinkImpl;
124 }
125
126 @Override
127 public void readExternal(ObjectInput objectInput) throws IOException {
128 linkId = objectInput.readLong();
129
130 companyId = objectInput.readLong();
131
132 userId = objectInput.readLong();
133 userName = objectInput.readUTF();
134 createDate = objectInput.readLong();
135
136 entryId1 = objectInput.readLong();
137
138 entryId2 = objectInput.readLong();
139
140 type = objectInput.readInt();
141
142 weight = objectInput.readInt();
143 }
144
145 @Override
146 public void writeExternal(ObjectOutput objectOutput)
147 throws IOException {
148 objectOutput.writeLong(linkId);
149
150 objectOutput.writeLong(companyId);
151
152 objectOutput.writeLong(userId);
153
154 if (userName == null) {
155 objectOutput.writeUTF(StringPool.BLANK);
156 }
157 else {
158 objectOutput.writeUTF(userName);
159 }
160
161 objectOutput.writeLong(createDate);
162
163 objectOutput.writeLong(entryId1);
164
165 objectOutput.writeLong(entryId2);
166
167 objectOutput.writeInt(type);
168
169 objectOutput.writeInt(weight);
170 }
171
172 public long linkId;
173 public long companyId;
174 public long userId;
175 public String userName;
176 public long createDate;
177 public long entryId1;
178 public long entryId2;
179 public int type;
180 public int weight;
181 }