001
014
015 package com.liferay.portlet.social.model.impl;
016
017 import com.liferay.portal.kernel.util.StringBundler;
018 import com.liferay.portal.kernel.util.StringPool;
019 import com.liferay.portal.model.CacheModel;
020
021 import com.liferay.portlet.social.model.SocialRelation;
022
023 import java.io.Externalizable;
024 import java.io.IOException;
025 import java.io.ObjectInput;
026 import java.io.ObjectOutput;
027
028
035 public class SocialRelationCacheModel implements CacheModel<SocialRelation>,
036 Externalizable {
037 @Override
038 public String toString() {
039 StringBundler sb = new StringBundler(15);
040
041 sb.append("{uuid=");
042 sb.append(uuid);
043 sb.append(", relationId=");
044 sb.append(relationId);
045 sb.append(", companyId=");
046 sb.append(companyId);
047 sb.append(", createDate=");
048 sb.append(createDate);
049 sb.append(", userId1=");
050 sb.append(userId1);
051 sb.append(", userId2=");
052 sb.append(userId2);
053 sb.append(", type=");
054 sb.append(type);
055 sb.append("}");
056
057 return sb.toString();
058 }
059
060 public SocialRelation toEntityModel() {
061 SocialRelationImpl socialRelationImpl = new SocialRelationImpl();
062
063 if (uuid == null) {
064 socialRelationImpl.setUuid(StringPool.BLANK);
065 }
066 else {
067 socialRelationImpl.setUuid(uuid);
068 }
069
070 socialRelationImpl.setRelationId(relationId);
071 socialRelationImpl.setCompanyId(companyId);
072 socialRelationImpl.setCreateDate(createDate);
073 socialRelationImpl.setUserId1(userId1);
074 socialRelationImpl.setUserId2(userId2);
075 socialRelationImpl.setType(type);
076
077 socialRelationImpl.resetOriginalValues();
078
079 return socialRelationImpl;
080 }
081
082 public void readExternal(ObjectInput objectInput) throws IOException {
083 uuid = objectInput.readUTF();
084 relationId = objectInput.readLong();
085 companyId = objectInput.readLong();
086 createDate = objectInput.readLong();
087 userId1 = objectInput.readLong();
088 userId2 = objectInput.readLong();
089 type = objectInput.readInt();
090 }
091
092 public void writeExternal(ObjectOutput objectOutput)
093 throws IOException {
094 if (uuid == null) {
095 objectOutput.writeUTF(StringPool.BLANK);
096 }
097 else {
098 objectOutput.writeUTF(uuid);
099 }
100
101 objectOutput.writeLong(relationId);
102 objectOutput.writeLong(companyId);
103 objectOutput.writeLong(createDate);
104 objectOutput.writeLong(userId1);
105 objectOutput.writeLong(userId2);
106 objectOutput.writeInt(type);
107 }
108
109 public String uuid;
110 public long relationId;
111 public long companyId;
112 public long createDate;
113 public long userId1;
114 public long userId2;
115 public int type;
116 }