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