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.UserGroup;
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 UserGroup in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see UserGroup
038     * @generated
039     */
040    @ProviderType
041    public class UserGroupCacheModel implements CacheModel<UserGroup>,
042            Externalizable, MVCCModel {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof UserGroupCacheModel)) {
050                            return false;
051                    }
052    
053                    UserGroupCacheModel userGroupCacheModel = (UserGroupCacheModel)obj;
054    
055                    if ((userGroupId == userGroupCacheModel.userGroupId) &&
056                                    (mvccVersion == userGroupCacheModel.mvccVersion)) {
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hashCode = HashUtil.hash(0, userGroupId);
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(25);
083    
084                    sb.append("{mvccVersion=");
085                    sb.append(mvccVersion);
086                    sb.append(", uuid=");
087                    sb.append(uuid);
088                    sb.append(", userGroupId=");
089                    sb.append(userGroupId);
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(", parentUserGroupId=");
101                    sb.append(parentUserGroupId);
102                    sb.append(", name=");
103                    sb.append(name);
104                    sb.append(", description=");
105                    sb.append(description);
106                    sb.append(", addedByLDAPImport=");
107                    sb.append(addedByLDAPImport);
108                    sb.append("}");
109    
110                    return sb.toString();
111            }
112    
113            @Override
114            public UserGroup toEntityModel() {
115                    UserGroupImpl userGroupImpl = new UserGroupImpl();
116    
117                    userGroupImpl.setMvccVersion(mvccVersion);
118    
119                    if (uuid == null) {
120                            userGroupImpl.setUuid(StringPool.BLANK);
121                    }
122                    else {
123                            userGroupImpl.setUuid(uuid);
124                    }
125    
126                    userGroupImpl.setUserGroupId(userGroupId);
127                    userGroupImpl.setCompanyId(companyId);
128                    userGroupImpl.setUserId(userId);
129    
130                    if (userName == null) {
131                            userGroupImpl.setUserName(StringPool.BLANK);
132                    }
133                    else {
134                            userGroupImpl.setUserName(userName);
135                    }
136    
137                    if (createDate == Long.MIN_VALUE) {
138                            userGroupImpl.setCreateDate(null);
139                    }
140                    else {
141                            userGroupImpl.setCreateDate(new Date(createDate));
142                    }
143    
144                    if (modifiedDate == Long.MIN_VALUE) {
145                            userGroupImpl.setModifiedDate(null);
146                    }
147                    else {
148                            userGroupImpl.setModifiedDate(new Date(modifiedDate));
149                    }
150    
151                    userGroupImpl.setParentUserGroupId(parentUserGroupId);
152    
153                    if (name == null) {
154                            userGroupImpl.setName(StringPool.BLANK);
155                    }
156                    else {
157                            userGroupImpl.setName(name);
158                    }
159    
160                    if (description == null) {
161                            userGroupImpl.setDescription(StringPool.BLANK);
162                    }
163                    else {
164                            userGroupImpl.setDescription(description);
165                    }
166    
167                    userGroupImpl.setAddedByLDAPImport(addedByLDAPImport);
168    
169                    userGroupImpl.resetOriginalValues();
170    
171                    return userGroupImpl;
172            }
173    
174            @Override
175            public void readExternal(ObjectInput objectInput) throws IOException {
176                    mvccVersion = objectInput.readLong();
177                    uuid = objectInput.readUTF();
178                    userGroupId = objectInput.readLong();
179                    companyId = objectInput.readLong();
180                    userId = objectInput.readLong();
181                    userName = objectInput.readUTF();
182                    createDate = objectInput.readLong();
183                    modifiedDate = objectInput.readLong();
184                    parentUserGroupId = objectInput.readLong();
185                    name = objectInput.readUTF();
186                    description = objectInput.readUTF();
187                    addedByLDAPImport = objectInput.readBoolean();
188            }
189    
190            @Override
191            public void writeExternal(ObjectOutput objectOutput)
192                    throws IOException {
193                    objectOutput.writeLong(mvccVersion);
194    
195                    if (uuid == null) {
196                            objectOutput.writeUTF(StringPool.BLANK);
197                    }
198                    else {
199                            objectOutput.writeUTF(uuid);
200                    }
201    
202                    objectOutput.writeLong(userGroupId);
203                    objectOutput.writeLong(companyId);
204                    objectOutput.writeLong(userId);
205    
206                    if (userName == null) {
207                            objectOutput.writeUTF(StringPool.BLANK);
208                    }
209                    else {
210                            objectOutput.writeUTF(userName);
211                    }
212    
213                    objectOutput.writeLong(createDate);
214                    objectOutput.writeLong(modifiedDate);
215                    objectOutput.writeLong(parentUserGroupId);
216    
217                    if (name == null) {
218                            objectOutput.writeUTF(StringPool.BLANK);
219                    }
220                    else {
221                            objectOutput.writeUTF(name);
222                    }
223    
224                    if (description == null) {
225                            objectOutput.writeUTF(StringPool.BLANK);
226                    }
227                    else {
228                            objectOutput.writeUTF(description);
229                    }
230    
231                    objectOutput.writeBoolean(addedByLDAPImport);
232            }
233    
234            public long mvccVersion;
235            public String uuid;
236            public long userGroupId;
237            public long companyId;
238            public long userId;
239            public String userName;
240            public long createDate;
241            public long modifiedDate;
242            public long parentUserGroupId;
243            public String name;
244            public String description;
245            public boolean addedByLDAPImport;
246    }