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.UserGroup;
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 UserGroup in entity cache.
034     *
035     * @author Brian Wing Shun Chan
036     * @see UserGroup
037     * @generated
038     */
039    @ProviderType
040    public class UserGroupCacheModel implements CacheModel<UserGroup>,
041            Externalizable, 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(25);
055    
056                    sb.append("{mvccVersion=");
057                    sb.append(mvccVersion);
058                    sb.append(", uuid=");
059                    sb.append(uuid);
060                    sb.append(", userGroupId=");
061                    sb.append(userGroupId);
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(", parentUserGroupId=");
073                    sb.append(parentUserGroupId);
074                    sb.append(", name=");
075                    sb.append(name);
076                    sb.append(", description=");
077                    sb.append(description);
078                    sb.append(", addedByLDAPImport=");
079                    sb.append(addedByLDAPImport);
080                    sb.append("}");
081    
082                    return sb.toString();
083            }
084    
085            @Override
086            public UserGroup toEntityModel() {
087                    UserGroupImpl userGroupImpl = new UserGroupImpl();
088    
089                    userGroupImpl.setMvccVersion(mvccVersion);
090    
091                    if (uuid == null) {
092                            userGroupImpl.setUuid(StringPool.BLANK);
093                    }
094                    else {
095                            userGroupImpl.setUuid(uuid);
096                    }
097    
098                    userGroupImpl.setUserGroupId(userGroupId);
099                    userGroupImpl.setCompanyId(companyId);
100                    userGroupImpl.setUserId(userId);
101    
102                    if (userName == null) {
103                            userGroupImpl.setUserName(StringPool.BLANK);
104                    }
105                    else {
106                            userGroupImpl.setUserName(userName);
107                    }
108    
109                    if (createDate == Long.MIN_VALUE) {
110                            userGroupImpl.setCreateDate(null);
111                    }
112                    else {
113                            userGroupImpl.setCreateDate(new Date(createDate));
114                    }
115    
116                    if (modifiedDate == Long.MIN_VALUE) {
117                            userGroupImpl.setModifiedDate(null);
118                    }
119                    else {
120                            userGroupImpl.setModifiedDate(new Date(modifiedDate));
121                    }
122    
123                    userGroupImpl.setParentUserGroupId(parentUserGroupId);
124    
125                    if (name == null) {
126                            userGroupImpl.setName(StringPool.BLANK);
127                    }
128                    else {
129                            userGroupImpl.setName(name);
130                    }
131    
132                    if (description == null) {
133                            userGroupImpl.setDescription(StringPool.BLANK);
134                    }
135                    else {
136                            userGroupImpl.setDescription(description);
137                    }
138    
139                    userGroupImpl.setAddedByLDAPImport(addedByLDAPImport);
140    
141                    userGroupImpl.resetOriginalValues();
142    
143                    return userGroupImpl;
144            }
145    
146            @Override
147            public void readExternal(ObjectInput objectInput) throws IOException {
148                    mvccVersion = objectInput.readLong();
149                    uuid = objectInput.readUTF();
150                    userGroupId = objectInput.readLong();
151                    companyId = objectInput.readLong();
152                    userId = objectInput.readLong();
153                    userName = objectInput.readUTF();
154                    createDate = objectInput.readLong();
155                    modifiedDate = objectInput.readLong();
156                    parentUserGroupId = objectInput.readLong();
157                    name = objectInput.readUTF();
158                    description = objectInput.readUTF();
159                    addedByLDAPImport = objectInput.readBoolean();
160            }
161    
162            @Override
163            public void writeExternal(ObjectOutput objectOutput)
164                    throws IOException {
165                    objectOutput.writeLong(mvccVersion);
166    
167                    if (uuid == null) {
168                            objectOutput.writeUTF(StringPool.BLANK);
169                    }
170                    else {
171                            objectOutput.writeUTF(uuid);
172                    }
173    
174                    objectOutput.writeLong(userGroupId);
175                    objectOutput.writeLong(companyId);
176                    objectOutput.writeLong(userId);
177    
178                    if (userName == null) {
179                            objectOutput.writeUTF(StringPool.BLANK);
180                    }
181                    else {
182                            objectOutput.writeUTF(userName);
183                    }
184    
185                    objectOutput.writeLong(createDate);
186                    objectOutput.writeLong(modifiedDate);
187                    objectOutput.writeLong(parentUserGroupId);
188    
189                    if (name == null) {
190                            objectOutput.writeUTF(StringPool.BLANK);
191                    }
192                    else {
193                            objectOutput.writeUTF(name);
194                    }
195    
196                    if (description == null) {
197                            objectOutput.writeUTF(StringPool.BLANK);
198                    }
199                    else {
200                            objectOutput.writeUTF(description);
201                    }
202    
203                    objectOutput.writeBoolean(addedByLDAPImport);
204            }
205    
206            public long mvccVersion;
207            public String uuid;
208            public long userGroupId;
209            public long companyId;
210            public long userId;
211            public String userName;
212            public long createDate;
213            public long modifiedDate;
214            public long parentUserGroupId;
215            public String name;
216            public String description;
217            public boolean addedByLDAPImport;
218    }