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.PortletPreferences;
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 PortletPreferencesCacheModel implements CacheModel<PortletPreferences>,
040 Externalizable, MVCCModel {
041 @Override
042 public boolean equals(Object obj) {
043 if (this == obj) {
044 return true;
045 }
046
047 if (!(obj instanceof PortletPreferencesCacheModel)) {
048 return false;
049 }
050
051 PortletPreferencesCacheModel portletPreferencesCacheModel = (PortletPreferencesCacheModel)obj;
052
053 if ((portletPreferencesId == portletPreferencesCacheModel.portletPreferencesId) &&
054 (mvccVersion == portletPreferencesCacheModel.mvccVersion)) {
055 return true;
056 }
057
058 return false;
059 }
060
061 @Override
062 public int hashCode() {
063 int hashCode = HashUtil.hash(0, portletPreferencesId);
064
065 return HashUtil.hash(hashCode, mvccVersion);
066 }
067
068 @Override
069 public long getMvccVersion() {
070 return mvccVersion;
071 }
072
073 @Override
074 public void setMvccVersion(long mvccVersion) {
075 this.mvccVersion = mvccVersion;
076 }
077
078 @Override
079 public String toString() {
080 StringBundler sb = new StringBundler(17);
081
082 sb.append("{mvccVersion=");
083 sb.append(mvccVersion);
084 sb.append(", portletPreferencesId=");
085 sb.append(portletPreferencesId);
086 sb.append(", companyId=");
087 sb.append(companyId);
088 sb.append(", ownerId=");
089 sb.append(ownerId);
090 sb.append(", ownerType=");
091 sb.append(ownerType);
092 sb.append(", plid=");
093 sb.append(plid);
094 sb.append(", portletId=");
095 sb.append(portletId);
096 sb.append(", preferences=");
097 sb.append(preferences);
098 sb.append("}");
099
100 return sb.toString();
101 }
102
103 @Override
104 public PortletPreferences toEntityModel() {
105 PortletPreferencesImpl portletPreferencesImpl = new PortletPreferencesImpl();
106
107 portletPreferencesImpl.setMvccVersion(mvccVersion);
108 portletPreferencesImpl.setPortletPreferencesId(portletPreferencesId);
109 portletPreferencesImpl.setCompanyId(companyId);
110 portletPreferencesImpl.setOwnerId(ownerId);
111 portletPreferencesImpl.setOwnerType(ownerType);
112 portletPreferencesImpl.setPlid(plid);
113
114 if (portletId == null) {
115 portletPreferencesImpl.setPortletId(StringPool.BLANK);
116 }
117 else {
118 portletPreferencesImpl.setPortletId(portletId);
119 }
120
121 if (preferences == null) {
122 portletPreferencesImpl.setPreferences(StringPool.BLANK);
123 }
124 else {
125 portletPreferencesImpl.setPreferences(preferences);
126 }
127
128 portletPreferencesImpl.resetOriginalValues();
129
130 return portletPreferencesImpl;
131 }
132
133 @Override
134 public void readExternal(ObjectInput objectInput) throws IOException {
135 mvccVersion = objectInput.readLong();
136 portletPreferencesId = objectInput.readLong();
137 companyId = objectInput.readLong();
138 ownerId = objectInput.readLong();
139 ownerType = objectInput.readInt();
140 plid = objectInput.readLong();
141 portletId = objectInput.readUTF();
142 preferences = objectInput.readUTF();
143 }
144
145 @Override
146 public void writeExternal(ObjectOutput objectOutput)
147 throws IOException {
148 objectOutput.writeLong(mvccVersion);
149 objectOutput.writeLong(portletPreferencesId);
150 objectOutput.writeLong(companyId);
151 objectOutput.writeLong(ownerId);
152 objectOutput.writeInt(ownerType);
153 objectOutput.writeLong(plid);
154
155 if (portletId == null) {
156 objectOutput.writeUTF(StringPool.BLANK);
157 }
158 else {
159 objectOutput.writeUTF(portletId);
160 }
161
162 if (preferences == null) {
163 objectOutput.writeUTF(StringPool.BLANK);
164 }
165 else {
166 objectOutput.writeUTF(preferences);
167 }
168 }
169
170 public long mvccVersion;
171 public long portletPreferencesId;
172 public long companyId;
173 public long ownerId;
174 public int ownerType;
175 public long plid;
176 public String portletId;
177 public String preferences;
178 }