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.Website;
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                    websiteId = objectInput.readLong();
185                    companyId = objectInput.readLong();
186                    userId = objectInput.readLong();
187                    userName = objectInput.readUTF();
188                    createDate = objectInput.readLong();
189                    modifiedDate = objectInput.readLong();
190                    classNameId = objectInput.readLong();
191                    classPK = objectInput.readLong();
192                    url = objectInput.readUTF();
193                    typeId = objectInput.readLong();
194                    primary = objectInput.readBoolean();
195                    lastPublishDate = objectInput.readLong();
196            }
197    
198            @Override
199            public void writeExternal(ObjectOutput objectOutput)
200                    throws IOException {
201                    objectOutput.writeLong(mvccVersion);
202    
203                    if (uuid == null) {
204                            objectOutput.writeUTF(StringPool.BLANK);
205                    }
206                    else {
207                            objectOutput.writeUTF(uuid);
208                    }
209    
210                    objectOutput.writeLong(websiteId);
211                    objectOutput.writeLong(companyId);
212                    objectOutput.writeLong(userId);
213    
214                    if (userName == null) {
215                            objectOutput.writeUTF(StringPool.BLANK);
216                    }
217                    else {
218                            objectOutput.writeUTF(userName);
219                    }
220    
221                    objectOutput.writeLong(createDate);
222                    objectOutput.writeLong(modifiedDate);
223                    objectOutput.writeLong(classNameId);
224                    objectOutput.writeLong(classPK);
225    
226                    if (url == null) {
227                            objectOutput.writeUTF(StringPool.BLANK);
228                    }
229                    else {
230                            objectOutput.writeUTF(url);
231                    }
232    
233                    objectOutput.writeLong(typeId);
234                    objectOutput.writeBoolean(primary);
235                    objectOutput.writeLong(lastPublishDate);
236            }
237    
238            public long mvccVersion;
239            public String uuid;
240            public long websiteId;
241            public long companyId;
242            public long userId;
243            public String userName;
244            public long createDate;
245            public long modifiedDate;
246            public long classNameId;
247            public long classPK;
248            public String url;
249            public long typeId;
250            public boolean primary;
251            public long lastPublishDate;
252    }