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.Organization;
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                    organizationId = objectInput.readLong();
210                    companyId = objectInput.readLong();
211                    userId = objectInput.readLong();
212                    userName = objectInput.readUTF();
213                    createDate = objectInput.readLong();
214                    modifiedDate = objectInput.readLong();
215                    parentOrganizationId = objectInput.readLong();
216                    treePath = objectInput.readUTF();
217                    name = objectInput.readUTF();
218                    type = objectInput.readUTF();
219                    recursable = objectInput.readBoolean();
220                    regionId = objectInput.readLong();
221                    countryId = objectInput.readLong();
222                    statusId = objectInput.readLong();
223                    comments = objectInput.readUTF();
224                    logoId = objectInput.readLong();
225            }
226    
227            @Override
228            public void writeExternal(ObjectOutput objectOutput)
229                    throws IOException {
230                    objectOutput.writeLong(mvccVersion);
231    
232                    if (uuid == null) {
233                            objectOutput.writeUTF(StringPool.BLANK);
234                    }
235                    else {
236                            objectOutput.writeUTF(uuid);
237                    }
238    
239                    objectOutput.writeLong(organizationId);
240                    objectOutput.writeLong(companyId);
241                    objectOutput.writeLong(userId);
242    
243                    if (userName == null) {
244                            objectOutput.writeUTF(StringPool.BLANK);
245                    }
246                    else {
247                            objectOutput.writeUTF(userName);
248                    }
249    
250                    objectOutput.writeLong(createDate);
251                    objectOutput.writeLong(modifiedDate);
252                    objectOutput.writeLong(parentOrganizationId);
253    
254                    if (treePath == null) {
255                            objectOutput.writeUTF(StringPool.BLANK);
256                    }
257                    else {
258                            objectOutput.writeUTF(treePath);
259                    }
260    
261                    if (name == null) {
262                            objectOutput.writeUTF(StringPool.BLANK);
263                    }
264                    else {
265                            objectOutput.writeUTF(name);
266                    }
267    
268                    if (type == null) {
269                            objectOutput.writeUTF(StringPool.BLANK);
270                    }
271                    else {
272                            objectOutput.writeUTF(type);
273                    }
274    
275                    objectOutput.writeBoolean(recursable);
276                    objectOutput.writeLong(regionId);
277                    objectOutput.writeLong(countryId);
278                    objectOutput.writeLong(statusId);
279    
280                    if (comments == null) {
281                            objectOutput.writeUTF(StringPool.BLANK);
282                    }
283                    else {
284                            objectOutput.writeUTF(comments);
285                    }
286    
287                    objectOutput.writeLong(logoId);
288            }
289    
290            public long mvccVersion;
291            public String uuid;
292            public long organizationId;
293            public long companyId;
294            public long userId;
295            public String userName;
296            public long createDate;
297            public long modifiedDate;
298            public long parentOrganizationId;
299            public String treePath;
300            public String name;
301            public String type;
302            public boolean recursable;
303            public long regionId;
304            public long countryId;
305            public long statusId;
306            public String comments;
307            public long logoId;
308    }