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(27);
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(", lastPublishDate=");
109                    sb.append(lastPublishDate);
110                    sb.append("}");
111    
112                    return sb.toString();
113            }
114    
115            @Override
116            public UserGroup toEntityModel() {
117                    UserGroupImpl userGroupImpl = new UserGroupImpl();
118    
119                    userGroupImpl.setMvccVersion(mvccVersion);
120    
121                    if (uuid == null) {
122                            userGroupImpl.setUuid(StringPool.BLANK);
123                    }
124                    else {
125                            userGroupImpl.setUuid(uuid);
126                    }
127    
128                    userGroupImpl.setUserGroupId(userGroupId);
129                    userGroupImpl.setCompanyId(companyId);
130                    userGroupImpl.setUserId(userId);
131    
132                    if (userName == null) {
133                            userGroupImpl.setUserName(StringPool.BLANK);
134                    }
135                    else {
136                            userGroupImpl.setUserName(userName);
137                    }
138    
139                    if (createDate == Long.MIN_VALUE) {
140                            userGroupImpl.setCreateDate(null);
141                    }
142                    else {
143                            userGroupImpl.setCreateDate(new Date(createDate));
144                    }
145    
146                    if (modifiedDate == Long.MIN_VALUE) {
147                            userGroupImpl.setModifiedDate(null);
148                    }
149                    else {
150                            userGroupImpl.setModifiedDate(new Date(modifiedDate));
151                    }
152    
153                    userGroupImpl.setParentUserGroupId(parentUserGroupId);
154    
155                    if (name == null) {
156                            userGroupImpl.setName(StringPool.BLANK);
157                    }
158                    else {
159                            userGroupImpl.setName(name);
160                    }
161    
162                    if (description == null) {
163                            userGroupImpl.setDescription(StringPool.BLANK);
164                    }
165                    else {
166                            userGroupImpl.setDescription(description);
167                    }
168    
169                    userGroupImpl.setAddedByLDAPImport(addedByLDAPImport);
170    
171                    if (lastPublishDate == Long.MIN_VALUE) {
172                            userGroupImpl.setLastPublishDate(null);
173                    }
174                    else {
175                            userGroupImpl.setLastPublishDate(new Date(lastPublishDate));
176                    }
177    
178                    userGroupImpl.resetOriginalValues();
179    
180                    return userGroupImpl;
181            }
182    
183            @Override
184            public void readExternal(ObjectInput objectInput) throws IOException {
185                    mvccVersion = objectInput.readLong();
186                    uuid = objectInput.readUTF();
187                    userGroupId = objectInput.readLong();
188                    companyId = objectInput.readLong();
189                    userId = objectInput.readLong();
190                    userName = objectInput.readUTF();
191                    createDate = objectInput.readLong();
192                    modifiedDate = objectInput.readLong();
193                    parentUserGroupId = objectInput.readLong();
194                    name = objectInput.readUTF();
195                    description = objectInput.readUTF();
196                    addedByLDAPImport = objectInput.readBoolean();
197                    lastPublishDate = objectInput.readLong();
198            }
199    
200            @Override
201            public void writeExternal(ObjectOutput objectOutput)
202                    throws IOException {
203                    objectOutput.writeLong(mvccVersion);
204    
205                    if (uuid == null) {
206                            objectOutput.writeUTF(StringPool.BLANK);
207                    }
208                    else {
209                            objectOutput.writeUTF(uuid);
210                    }
211    
212                    objectOutput.writeLong(userGroupId);
213                    objectOutput.writeLong(companyId);
214                    objectOutput.writeLong(userId);
215    
216                    if (userName == null) {
217                            objectOutput.writeUTF(StringPool.BLANK);
218                    }
219                    else {
220                            objectOutput.writeUTF(userName);
221                    }
222    
223                    objectOutput.writeLong(createDate);
224                    objectOutput.writeLong(modifiedDate);
225                    objectOutput.writeLong(parentUserGroupId);
226    
227                    if (name == null) {
228                            objectOutput.writeUTF(StringPool.BLANK);
229                    }
230                    else {
231                            objectOutput.writeUTF(name);
232                    }
233    
234                    if (description == null) {
235                            objectOutput.writeUTF(StringPool.BLANK);
236                    }
237                    else {
238                            objectOutput.writeUTF(description);
239                    }
240    
241                    objectOutput.writeBoolean(addedByLDAPImport);
242                    objectOutput.writeLong(lastPublishDate);
243            }
244    
245            public long mvccVersion;
246            public String uuid;
247            public long userGroupId;
248            public long companyId;
249            public long userId;
250            public String userName;
251            public long createDate;
252            public long modifiedDate;
253            public long parentUserGroupId;
254            public String name;
255            public String description;
256            public boolean addedByLDAPImport;
257            public long lastPublishDate;
258    }