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.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.CacheModel;
022    import com.liferay.portal.model.MVCCModel;
023    import com.liferay.portal.model.Role;
024    
025    import java.io.Externalizable;
026    import java.io.IOException;
027    import java.io.ObjectInput;
028    import java.io.ObjectOutput;
029    
030    import java.util.Date;
031    
032    /**
033     * The cache model class for representing Role in entity cache.
034     *
035     * @author Brian Wing Shun Chan
036     * @see Role
037     * @generated
038     */
039    @ProviderType
040    public class RoleCacheModel implements CacheModel<Role>, Externalizable,
041            MVCCModel {
042            @Override
043            public long getMvccVersion() {
044                    return mvccVersion;
045            }
046    
047            @Override
048            public void setMvccVersion(long mvccVersion) {
049                    this.mvccVersion = mvccVersion;
050            }
051    
052            @Override
053            public String toString() {
054                    StringBundler sb = new StringBundler(31);
055    
056                    sb.append("{mvccVersion=");
057                    sb.append(mvccVersion);
058                    sb.append(", uuid=");
059                    sb.append(uuid);
060                    sb.append(", roleId=");
061                    sb.append(roleId);
062                    sb.append(", companyId=");
063                    sb.append(companyId);
064                    sb.append(", userId=");
065                    sb.append(userId);
066                    sb.append(", userName=");
067                    sb.append(userName);
068                    sb.append(", createDate=");
069                    sb.append(createDate);
070                    sb.append(", modifiedDate=");
071                    sb.append(modifiedDate);
072                    sb.append(", classNameId=");
073                    sb.append(classNameId);
074                    sb.append(", classPK=");
075                    sb.append(classPK);
076                    sb.append(", name=");
077                    sb.append(name);
078                    sb.append(", title=");
079                    sb.append(title);
080                    sb.append(", description=");
081                    sb.append(description);
082                    sb.append(", type=");
083                    sb.append(type);
084                    sb.append(", subtype=");
085                    sb.append(subtype);
086                    sb.append("}");
087    
088                    return sb.toString();
089            }
090    
091            @Override
092            public Role toEntityModel() {
093                    RoleImpl roleImpl = new RoleImpl();
094    
095                    roleImpl.setMvccVersion(mvccVersion);
096    
097                    if (uuid == null) {
098                            roleImpl.setUuid(StringPool.BLANK);
099                    }
100                    else {
101                            roleImpl.setUuid(uuid);
102                    }
103    
104                    roleImpl.setRoleId(roleId);
105                    roleImpl.setCompanyId(companyId);
106                    roleImpl.setUserId(userId);
107    
108                    if (userName == null) {
109                            roleImpl.setUserName(StringPool.BLANK);
110                    }
111                    else {
112                            roleImpl.setUserName(userName);
113                    }
114    
115                    if (createDate == Long.MIN_VALUE) {
116                            roleImpl.setCreateDate(null);
117                    }
118                    else {
119                            roleImpl.setCreateDate(new Date(createDate));
120                    }
121    
122                    if (modifiedDate == Long.MIN_VALUE) {
123                            roleImpl.setModifiedDate(null);
124                    }
125                    else {
126                            roleImpl.setModifiedDate(new Date(modifiedDate));
127                    }
128    
129                    roleImpl.setClassNameId(classNameId);
130                    roleImpl.setClassPK(classPK);
131    
132                    if (name == null) {
133                            roleImpl.setName(StringPool.BLANK);
134                    }
135                    else {
136                            roleImpl.setName(name);
137                    }
138    
139                    if (title == null) {
140                            roleImpl.setTitle(StringPool.BLANK);
141                    }
142                    else {
143                            roleImpl.setTitle(title);
144                    }
145    
146                    if (description == null) {
147                            roleImpl.setDescription(StringPool.BLANK);
148                    }
149                    else {
150                            roleImpl.setDescription(description);
151                    }
152    
153                    roleImpl.setType(type);
154    
155                    if (subtype == null) {
156                            roleImpl.setSubtype(StringPool.BLANK);
157                    }
158                    else {
159                            roleImpl.setSubtype(subtype);
160                    }
161    
162                    roleImpl.resetOriginalValues();
163    
164                    return roleImpl;
165            }
166    
167            @Override
168            public void readExternal(ObjectInput objectInput) throws IOException {
169                    mvccVersion = objectInput.readLong();
170                    uuid = objectInput.readUTF();
171                    roleId = objectInput.readLong();
172                    companyId = objectInput.readLong();
173                    userId = objectInput.readLong();
174                    userName = objectInput.readUTF();
175                    createDate = objectInput.readLong();
176                    modifiedDate = objectInput.readLong();
177                    classNameId = objectInput.readLong();
178                    classPK = objectInput.readLong();
179                    name = objectInput.readUTF();
180                    title = objectInput.readUTF();
181                    description = objectInput.readUTF();
182                    type = objectInput.readInt();
183                    subtype = objectInput.readUTF();
184            }
185    
186            @Override
187            public void writeExternal(ObjectOutput objectOutput)
188                    throws IOException {
189                    objectOutput.writeLong(mvccVersion);
190    
191                    if (uuid == null) {
192                            objectOutput.writeUTF(StringPool.BLANK);
193                    }
194                    else {
195                            objectOutput.writeUTF(uuid);
196                    }
197    
198                    objectOutput.writeLong(roleId);
199                    objectOutput.writeLong(companyId);
200                    objectOutput.writeLong(userId);
201    
202                    if (userName == null) {
203                            objectOutput.writeUTF(StringPool.BLANK);
204                    }
205                    else {
206                            objectOutput.writeUTF(userName);
207                    }
208    
209                    objectOutput.writeLong(createDate);
210                    objectOutput.writeLong(modifiedDate);
211                    objectOutput.writeLong(classNameId);
212                    objectOutput.writeLong(classPK);
213    
214                    if (name == null) {
215                            objectOutput.writeUTF(StringPool.BLANK);
216                    }
217                    else {
218                            objectOutput.writeUTF(name);
219                    }
220    
221                    if (title == null) {
222                            objectOutput.writeUTF(StringPool.BLANK);
223                    }
224                    else {
225                            objectOutput.writeUTF(title);
226                    }
227    
228                    if (description == null) {
229                            objectOutput.writeUTF(StringPool.BLANK);
230                    }
231                    else {
232                            objectOutput.writeUTF(description);
233                    }
234    
235                    objectOutput.writeInt(type);
236    
237                    if (subtype == null) {
238                            objectOutput.writeUTF(StringPool.BLANK);
239                    }
240                    else {
241                            objectOutput.writeUTF(subtype);
242                    }
243            }
244    
245            public long mvccVersion;
246            public String uuid;
247            public long roleId;
248            public long companyId;
249            public long userId;
250            public String userName;
251            public long createDate;
252            public long modifiedDate;
253            public long classNameId;
254            public long classPK;
255            public String name;
256            public String title;
257            public String description;
258            public int type;
259            public String subtype;
260    }