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.Organization;
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 Organization in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see Organization
038     * @generated
039     */
040    @ProviderType
041    public class OrganizationCacheModel implements CacheModel<Organization>,
042            Externalizable, MVCCModel {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof OrganizationCacheModel)) {
050                            return false;
051                    }
052    
053                    OrganizationCacheModel organizationCacheModel = (OrganizationCacheModel)obj;
054    
055                    if ((organizationId == organizationCacheModel.organizationId) &&
056                                    (mvccVersion == organizationCacheModel.mvccVersion)) {
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hashCode = HashUtil.hash(0, organizationId);
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(37);
083    
084                    sb.append("{mvccVersion=");
085                    sb.append(mvccVersion);
086                    sb.append(", uuid=");
087                    sb.append(uuid);
088                    sb.append(", organizationId=");
089                    sb.append(organizationId);
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(", parentOrganizationId=");
101                    sb.append(parentOrganizationId);
102                    sb.append(", treePath=");
103                    sb.append(treePath);
104                    sb.append(", name=");
105                    sb.append(name);
106                    sb.append(", type=");
107                    sb.append(type);
108                    sb.append(", recursable=");
109                    sb.append(recursable);
110                    sb.append(", regionId=");
111                    sb.append(regionId);
112                    sb.append(", countryId=");
113                    sb.append(countryId);
114                    sb.append(", statusId=");
115                    sb.append(statusId);
116                    sb.append(", comments=");
117                    sb.append(comments);
118                    sb.append(", logoId=");
119                    sb.append(logoId);
120                    sb.append("}");
121    
122                    return sb.toString();
123            }
124    
125            @Override
126            public Organization toEntityModel() {
127                    OrganizationImpl organizationImpl = new OrganizationImpl();
128    
129                    organizationImpl.setMvccVersion(mvccVersion);
130    
131                    if (uuid == null) {
132                            organizationImpl.setUuid(StringPool.BLANK);
133                    }
134                    else {
135                            organizationImpl.setUuid(uuid);
136                    }
137    
138                    organizationImpl.setOrganizationId(organizationId);
139                    organizationImpl.setCompanyId(companyId);
140                    organizationImpl.setUserId(userId);
141    
142                    if (userName == null) {
143                            organizationImpl.setUserName(StringPool.BLANK);
144                    }
145                    else {
146                            organizationImpl.setUserName(userName);
147                    }
148    
149                    if (createDate == Long.MIN_VALUE) {
150                            organizationImpl.setCreateDate(null);
151                    }
152                    else {
153                            organizationImpl.setCreateDate(new Date(createDate));
154                    }
155    
156                    if (modifiedDate == Long.MIN_VALUE) {
157                            organizationImpl.setModifiedDate(null);
158                    }
159                    else {
160                            organizationImpl.setModifiedDate(new Date(modifiedDate));
161                    }
162    
163                    organizationImpl.setParentOrganizationId(parentOrganizationId);
164    
165                    if (treePath == null) {
166                            organizationImpl.setTreePath(StringPool.BLANK);
167                    }
168                    else {
169                            organizationImpl.setTreePath(treePath);
170                    }
171    
172                    if (name == null) {
173                            organizationImpl.setName(StringPool.BLANK);
174                    }
175                    else {
176                            organizationImpl.setName(name);
177                    }
178    
179                    if (type == null) {
180                            organizationImpl.setType(StringPool.BLANK);
181                    }
182                    else {
183                            organizationImpl.setType(type);
184                    }
185    
186                    organizationImpl.setRecursable(recursable);
187                    organizationImpl.setRegionId(regionId);
188                    organizationImpl.setCountryId(countryId);
189                    organizationImpl.setStatusId(statusId);
190    
191                    if (comments == null) {
192                            organizationImpl.setComments(StringPool.BLANK);
193                    }
194                    else {
195                            organizationImpl.setComments(comments);
196                    }
197    
198                    organizationImpl.setLogoId(logoId);
199    
200                    organizationImpl.resetOriginalValues();
201    
202                    return organizationImpl;
203            }
204    
205            @Override
206            public void readExternal(ObjectInput objectInput) throws IOException {
207                    mvccVersion = objectInput.readLong();
208                    uuid = objectInput.readUTF();
209    
210                    organizationId = objectInput.readLong();
211    
212                    companyId = objectInput.readLong();
213    
214                    userId = objectInput.readLong();
215                    userName = objectInput.readUTF();
216                    createDate = objectInput.readLong();
217                    modifiedDate = objectInput.readLong();
218    
219                    parentOrganizationId = objectInput.readLong();
220                    treePath = objectInput.readUTF();
221                    name = objectInput.readUTF();
222                    type = objectInput.readUTF();
223    
224                    recursable = objectInput.readBoolean();
225    
226                    regionId = objectInput.readLong();
227    
228                    countryId = objectInput.readLong();
229    
230                    statusId = objectInput.readLong();
231                    comments = objectInput.readUTF();
232    
233                    logoId = objectInput.readLong();
234            }
235    
236            @Override
237            public void writeExternal(ObjectOutput objectOutput)
238                    throws IOException {
239                    objectOutput.writeLong(mvccVersion);
240    
241                    if (uuid == null) {
242                            objectOutput.writeUTF(StringPool.BLANK);
243                    }
244                    else {
245                            objectOutput.writeUTF(uuid);
246                    }
247    
248                    objectOutput.writeLong(organizationId);
249    
250                    objectOutput.writeLong(companyId);
251    
252                    objectOutput.writeLong(userId);
253    
254                    if (userName == null) {
255                            objectOutput.writeUTF(StringPool.BLANK);
256                    }
257                    else {
258                            objectOutput.writeUTF(userName);
259                    }
260    
261                    objectOutput.writeLong(createDate);
262                    objectOutput.writeLong(modifiedDate);
263    
264                    objectOutput.writeLong(parentOrganizationId);
265    
266                    if (treePath == null) {
267                            objectOutput.writeUTF(StringPool.BLANK);
268                    }
269                    else {
270                            objectOutput.writeUTF(treePath);
271                    }
272    
273                    if (name == null) {
274                            objectOutput.writeUTF(StringPool.BLANK);
275                    }
276                    else {
277                            objectOutput.writeUTF(name);
278                    }
279    
280                    if (type == null) {
281                            objectOutput.writeUTF(StringPool.BLANK);
282                    }
283                    else {
284                            objectOutput.writeUTF(type);
285                    }
286    
287                    objectOutput.writeBoolean(recursable);
288    
289                    objectOutput.writeLong(regionId);
290    
291                    objectOutput.writeLong(countryId);
292    
293                    objectOutput.writeLong(statusId);
294    
295                    if (comments == null) {
296                            objectOutput.writeUTF(StringPool.BLANK);
297                    }
298                    else {
299                            objectOutput.writeUTF(comments);
300                    }
301    
302                    objectOutput.writeLong(logoId);
303            }
304    
305            public long mvccVersion;
306            public String uuid;
307            public long organizationId;
308            public long companyId;
309            public long userId;
310            public String userName;
311            public long createDate;
312            public long modifiedDate;
313            public long parentOrganizationId;
314            public String treePath;
315            public String name;
316            public String type;
317            public boolean recursable;
318            public long regionId;
319            public long countryId;
320            public long statusId;
321            public String comments;
322            public long logoId;
323    }