001
014
015 package com.liferay.portlet.social.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.social.kernel.model.SocialRelation;
025
026 import java.io.Externalizable;
027 import java.io.IOException;
028 import java.io.ObjectInput;
029 import java.io.ObjectOutput;
030
031
038 @ProviderType
039 public class SocialRelationCacheModel implements CacheModel<SocialRelation>,
040 Externalizable {
041 @Override
042 public boolean equals(Object obj) {
043 if (this == obj) {
044 return true;
045 }
046
047 if (!(obj instanceof SocialRelationCacheModel)) {
048 return false;
049 }
050
051 SocialRelationCacheModel socialRelationCacheModel = (SocialRelationCacheModel)obj;
052
053 if (relationId == socialRelationCacheModel.relationId) {
054 return true;
055 }
056
057 return false;
058 }
059
060 @Override
061 public int hashCode() {
062 return HashUtil.hash(0, relationId);
063 }
064
065 @Override
066 public String toString() {
067 StringBundler sb = new StringBundler(15);
068
069 sb.append("{uuid=");
070 sb.append(uuid);
071 sb.append(", relationId=");
072 sb.append(relationId);
073 sb.append(", companyId=");
074 sb.append(companyId);
075 sb.append(", createDate=");
076 sb.append(createDate);
077 sb.append(", userId1=");
078 sb.append(userId1);
079 sb.append(", userId2=");
080 sb.append(userId2);
081 sb.append(", type=");
082 sb.append(type);
083 sb.append("}");
084
085 return sb.toString();
086 }
087
088 @Override
089 public SocialRelation toEntityModel() {
090 SocialRelationImpl socialRelationImpl = new SocialRelationImpl();
091
092 if (uuid == null) {
093 socialRelationImpl.setUuid(StringPool.BLANK);
094 }
095 else {
096 socialRelationImpl.setUuid(uuid);
097 }
098
099 socialRelationImpl.setRelationId(relationId);
100 socialRelationImpl.setCompanyId(companyId);
101 socialRelationImpl.setCreateDate(createDate);
102 socialRelationImpl.setUserId1(userId1);
103 socialRelationImpl.setUserId2(userId2);
104 socialRelationImpl.setType(type);
105
106 socialRelationImpl.resetOriginalValues();
107
108 return socialRelationImpl;
109 }
110
111 @Override
112 public void readExternal(ObjectInput objectInput) throws IOException {
113 uuid = objectInput.readUTF();
114
115 relationId = objectInput.readLong();
116
117 companyId = objectInput.readLong();
118
119 createDate = objectInput.readLong();
120
121 userId1 = objectInput.readLong();
122
123 userId2 = objectInput.readLong();
124
125 type = objectInput.readInt();
126 }
127
128 @Override
129 public void writeExternal(ObjectOutput objectOutput)
130 throws IOException {
131 if (uuid == null) {
132 objectOutput.writeUTF(StringPool.BLANK);
133 }
134 else {
135 objectOutput.writeUTF(uuid);
136 }
137
138 objectOutput.writeLong(relationId);
139
140 objectOutput.writeLong(companyId);
141
142 objectOutput.writeLong(createDate);
143
144 objectOutput.writeLong(userId1);
145
146 objectOutput.writeLong(userId2);
147
148 objectOutput.writeInt(type);
149 }
150
151 public String uuid;
152 public long relationId;
153 public long companyId;
154 public long createDate;
155 public long userId1;
156 public long userId2;
157 public int type;
158 }