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.Team;
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 TeamCacheModel implements CacheModel<Team>, Externalizable,
042 MVCCModel {
043 @Override
044 public boolean equals(Object obj) {
045 if (this == obj) {
046 return true;
047 }
048
049 if (!(obj instanceof TeamCacheModel)) {
050 return false;
051 }
052
053 TeamCacheModel teamCacheModel = (TeamCacheModel)obj;
054
055 if ((teamId == teamCacheModel.teamId) &&
056 (mvccVersion == teamCacheModel.mvccVersion)) {
057 return true;
058 }
059
060 return false;
061 }
062
063 @Override
064 public int hashCode() {
065 int hashCode = HashUtil.hash(0, teamId);
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(21);
083
084 sb.append("{mvccVersion=");
085 sb.append(mvccVersion);
086 sb.append(", teamId=");
087 sb.append(teamId);
088 sb.append(", companyId=");
089 sb.append(companyId);
090 sb.append(", userId=");
091 sb.append(userId);
092 sb.append(", userName=");
093 sb.append(userName);
094 sb.append(", createDate=");
095 sb.append(createDate);
096 sb.append(", modifiedDate=");
097 sb.append(modifiedDate);
098 sb.append(", groupId=");
099 sb.append(groupId);
100 sb.append(", name=");
101 sb.append(name);
102 sb.append(", description=");
103 sb.append(description);
104 sb.append("}");
105
106 return sb.toString();
107 }
108
109 @Override
110 public Team toEntityModel() {
111 TeamImpl teamImpl = new TeamImpl();
112
113 teamImpl.setMvccVersion(mvccVersion);
114 teamImpl.setTeamId(teamId);
115 teamImpl.setCompanyId(companyId);
116 teamImpl.setUserId(userId);
117
118 if (userName == null) {
119 teamImpl.setUserName(StringPool.BLANK);
120 }
121 else {
122 teamImpl.setUserName(userName);
123 }
124
125 if (createDate == Long.MIN_VALUE) {
126 teamImpl.setCreateDate(null);
127 }
128 else {
129 teamImpl.setCreateDate(new Date(createDate));
130 }
131
132 if (modifiedDate == Long.MIN_VALUE) {
133 teamImpl.setModifiedDate(null);
134 }
135 else {
136 teamImpl.setModifiedDate(new Date(modifiedDate));
137 }
138
139 teamImpl.setGroupId(groupId);
140
141 if (name == null) {
142 teamImpl.setName(StringPool.BLANK);
143 }
144 else {
145 teamImpl.setName(name);
146 }
147
148 if (description == null) {
149 teamImpl.setDescription(StringPool.BLANK);
150 }
151 else {
152 teamImpl.setDescription(description);
153 }
154
155 teamImpl.resetOriginalValues();
156
157 return teamImpl;
158 }
159
160 @Override
161 public void readExternal(ObjectInput objectInput) throws IOException {
162 mvccVersion = objectInput.readLong();
163 teamId = objectInput.readLong();
164 companyId = objectInput.readLong();
165 userId = objectInput.readLong();
166 userName = objectInput.readUTF();
167 createDate = objectInput.readLong();
168 modifiedDate = objectInput.readLong();
169 groupId = objectInput.readLong();
170 name = objectInput.readUTF();
171 description = objectInput.readUTF();
172 }
173
174 @Override
175 public void writeExternal(ObjectOutput objectOutput)
176 throws IOException {
177 objectOutput.writeLong(mvccVersion);
178 objectOutput.writeLong(teamId);
179 objectOutput.writeLong(companyId);
180 objectOutput.writeLong(userId);
181
182 if (userName == null) {
183 objectOutput.writeUTF(StringPool.BLANK);
184 }
185 else {
186 objectOutput.writeUTF(userName);
187 }
188
189 objectOutput.writeLong(createDate);
190 objectOutput.writeLong(modifiedDate);
191 objectOutput.writeLong(groupId);
192
193 if (name == null) {
194 objectOutput.writeUTF(StringPool.BLANK);
195 }
196 else {
197 objectOutput.writeUTF(name);
198 }
199
200 if (description == null) {
201 objectOutput.writeUTF(StringPool.BLANK);
202 }
203 else {
204 objectOutput.writeUTF(description);
205 }
206 }
207
208 public long mvccVersion;
209 public long teamId;
210 public long companyId;
211 public long userId;
212 public String userName;
213 public long createDate;
214 public long modifiedDate;
215 public long groupId;
216 public String name;
217 public String description;
218 }