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.model.CacheModel;
020    import com.liferay.portal.kernel.model.MVCCModel;
021    import com.liferay.portal.kernel.model.Role;
022    import com.liferay.portal.kernel.util.HashUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
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    
200                    roleId = objectInput.readLong();
201    
202                    companyId = objectInput.readLong();
203    
204                    userId = objectInput.readLong();
205                    userName = objectInput.readUTF();
206                    createDate = objectInput.readLong();
207                    modifiedDate = objectInput.readLong();
208    
209                    classNameId = objectInput.readLong();
210    
211                    classPK = objectInput.readLong();
212                    name = objectInput.readUTF();
213                    title = objectInput.readUTF();
214                    description = objectInput.readUTF();
215    
216                    type = objectInput.readInt();
217                    subtype = objectInput.readUTF();
218            }
219    
220            @Override
221            public void writeExternal(ObjectOutput objectOutput)
222                    throws IOException {
223                    objectOutput.writeLong(mvccVersion);
224    
225                    if (uuid == null) {
226                            objectOutput.writeUTF(StringPool.BLANK);
227                    }
228                    else {
229                            objectOutput.writeUTF(uuid);
230                    }
231    
232                    objectOutput.writeLong(roleId);
233    
234                    objectOutput.writeLong(companyId);
235    
236                    objectOutput.writeLong(userId);
237    
238                    if (userName == null) {
239                            objectOutput.writeUTF(StringPool.BLANK);
240                    }
241                    else {
242                            objectOutput.writeUTF(userName);
243                    }
244    
245                    objectOutput.writeLong(createDate);
246                    objectOutput.writeLong(modifiedDate);
247    
248                    objectOutput.writeLong(classNameId);
249    
250                    objectOutput.writeLong(classPK);
251    
252                    if (name == null) {
253                            objectOutput.writeUTF(StringPool.BLANK);
254                    }
255                    else {
256                            objectOutput.writeUTF(name);
257                    }
258    
259                    if (title == null) {
260                            objectOutput.writeUTF(StringPool.BLANK);
261                    }
262                    else {
263                            objectOutput.writeUTF(title);
264                    }
265    
266                    if (description == null) {
267                            objectOutput.writeUTF(StringPool.BLANK);
268                    }
269                    else {
270                            objectOutput.writeUTF(description);
271                    }
272    
273                    objectOutput.writeInt(type);
274    
275                    if (subtype == null) {
276                            objectOutput.writeUTF(StringPool.BLANK);
277                    }
278                    else {
279                            objectOutput.writeUTF(subtype);
280                    }
281            }
282    
283            public long mvccVersion;
284            public String uuid;
285            public long roleId;
286            public long companyId;
287            public long userId;
288            public String userName;
289            public long createDate;
290            public long modifiedDate;
291            public long classNameId;
292            public long classPK;
293            public String name;
294            public String title;
295            public String description;
296            public int type;
297            public String subtype;
298    }