001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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.Role;
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    /**
034     * The cache model class for representing Role in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see Role
038     * @generated
039     */
040    @ProviderType
041    public class RoleCacheModel implements CacheModel<Role>, Externalizable,
042            MVCCModel {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof RoleCacheModel)) {
050                            return false;
051                    }
052    
053                    RoleCacheModel roleCacheModel = (RoleCacheModel)obj;
054    
055                    if ((roleId == roleCacheModel.roleId) &&
056                                    (mvccVersion == roleCacheModel.mvccVersion)) {
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hashCode = HashUtil.hash(0, roleId);
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(31);
083    
084                    sb.append("{mvccVersion=");
085                    sb.append(mvccVersion);
086                    sb.append(", uuid=");
087                    sb.append(uuid);
088                    sb.append(", roleId=");
089                    sb.append(roleId);
090                    sb.append(", companyId=");
091                    sb.append(companyId);
092                    sb.append(", userId=");
093                    sb.append(userId);
094                    sb.append(", userName=");
095                    sb.append(userName);
096                    sb.append(", createDate=");
097                    sb.append(createDate);
098                    sb.append(", modifiedDate=");
099                    sb.append(modifiedDate);
100                    sb.append(", classNameId=");
101                    sb.append(classNameId);
102                    sb.append(", classPK=");
103                    sb.append(classPK);
104                    sb.append(", name=");
105                    sb.append(name);
106                    sb.append(", title=");
107                    sb.append(title);
108                    sb.append(", description=");
109                    sb.append(description);
110                    sb.append(", type=");
111                    sb.append(type);
112                    sb.append(", subtype=");
113                    sb.append(subtype);
114                    sb.append("}");
115    
116                    return sb.toString();
117            }
118    
119            @Override
120            public Role toEntityModel() {
121                    RoleImpl roleImpl = new RoleImpl();
122    
123                    roleImpl.setMvccVersion(mvccVersion);
124    
125                    if (uuid == null) {
126                            roleImpl.setUuid(StringPool.BLANK);
127                    }
128                    else {
129                            roleImpl.setUuid(uuid);
130                    }
131    
132                    roleImpl.setRoleId(roleId);
133                    roleImpl.setCompanyId(companyId);
134                    roleImpl.setUserId(userId);
135    
136                    if (userName == null) {
137                            roleImpl.setUserName(StringPool.BLANK);
138                    }
139                    else {
140                            roleImpl.setUserName(userName);
141                    }
142    
143                    if (createDate == Long.MIN_VALUE) {
144                            roleImpl.setCreateDate(null);
145                    }
146                    else {
147                            roleImpl.setCreateDate(new Date(createDate));
148                    }
149    
150                    if (modifiedDate == Long.MIN_VALUE) {
151                            roleImpl.setModifiedDate(null);
152                    }
153                    else {
154                            roleImpl.setModifiedDate(new Date(modifiedDate));
155                    }
156    
157                    roleImpl.setClassNameId(classNameId);
158                    roleImpl.setClassPK(classPK);
159    
160                    if (name == null) {
161                            roleImpl.setName(StringPool.BLANK);
162                    }
163                    else {
164                            roleImpl.setName(name);
165                    }
166    
167                    if (title == null) {
168                            roleImpl.setTitle(StringPool.BLANK);
169                    }
170                    else {
171                            roleImpl.setTitle(title);
172                    }
173    
174                    if (description == null) {
175                            roleImpl.setDescription(StringPool.BLANK);
176                    }
177                    else {
178                            roleImpl.setDescription(description);
179                    }
180    
181                    roleImpl.setType(type);
182    
183                    if (subtype == null) {
184                            roleImpl.setSubtype(StringPool.BLANK);
185                    }
186                    else {
187                            roleImpl.setSubtype(subtype);
188                    }
189    
190                    roleImpl.resetOriginalValues();
191    
192                    return roleImpl;
193            }
194    
195            @Override
196            public void readExternal(ObjectInput objectInput) throws IOException {
197                    mvccVersion = objectInput.readLong();
198                    uuid = objectInput.readUTF();
199                    roleId = objectInput.readLong();
200                    companyId = objectInput.readLong();
201                    userId = objectInput.readLong();
202                    userName = objectInput.readUTF();
203                    createDate = objectInput.readLong();
204                    modifiedDate = objectInput.readLong();
205                    classNameId = objectInput.readLong();
206                    classPK = objectInput.readLong();
207                    name = objectInput.readUTF();
208                    title = objectInput.readUTF();
209                    description = objectInput.readUTF();
210                    type = objectInput.readInt();
211                    subtype = objectInput.readUTF();
212            }
213    
214            @Override
215            public void writeExternal(ObjectOutput objectOutput)
216                    throws IOException {
217                    objectOutput.writeLong(mvccVersion);
218    
219                    if (uuid == null) {
220                            objectOutput.writeUTF(StringPool.BLANK);
221                    }
222                    else {
223                            objectOutput.writeUTF(uuid);
224                    }
225    
226                    objectOutput.writeLong(roleId);
227                    objectOutput.writeLong(companyId);
228                    objectOutput.writeLong(userId);
229    
230                    if (userName == null) {
231                            objectOutput.writeUTF(StringPool.BLANK);
232                    }
233                    else {
234                            objectOutput.writeUTF(userName);
235                    }
236    
237                    objectOutput.writeLong(createDate);
238                    objectOutput.writeLong(modifiedDate);
239                    objectOutput.writeLong(classNameId);
240                    objectOutput.writeLong(classPK);
241    
242                    if (name == null) {
243                            objectOutput.writeUTF(StringPool.BLANK);
244                    }
245                    else {
246                            objectOutput.writeUTF(name);
247                    }
248    
249                    if (title == null) {
250                            objectOutput.writeUTF(StringPool.BLANK);
251                    }
252                    else {
253                            objectOutput.writeUTF(title);
254                    }
255    
256                    if (description == null) {
257                            objectOutput.writeUTF(StringPool.BLANK);
258                    }
259                    else {
260                            objectOutput.writeUTF(description);
261                    }
262    
263                    objectOutput.writeInt(type);
264    
265                    if (subtype == null) {
266                            objectOutput.writeUTF(StringPool.BLANK);
267                    }
268                    else {
269                            objectOutput.writeUTF(subtype);
270                    }
271            }
272    
273            public long mvccVersion;
274            public String uuid;
275            public long roleId;
276            public long companyId;
277            public long userId;
278            public String userName;
279            public long createDate;
280            public long modifiedDate;
281            public long classNameId;
282            public long classPK;
283            public String name;
284            public String title;
285            public String description;
286            public int type;
287            public String subtype;
288    }