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