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.LayoutFriendlyURL;
021    import com.liferay.portal.kernel.model.MVCCModel;
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 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    
190                    layoutFriendlyURLId = objectInput.readLong();
191    
192                    groupId = objectInput.readLong();
193    
194                    companyId = objectInput.readLong();
195    
196                    userId = objectInput.readLong();
197                    userName = objectInput.readUTF();
198                    createDate = objectInput.readLong();
199                    modifiedDate = objectInput.readLong();
200    
201                    plid = objectInput.readLong();
202    
203                    privateLayout = objectInput.readBoolean();
204                    friendlyURL = objectInput.readUTF();
205                    languageId = objectInput.readUTF();
206                    lastPublishDate = objectInput.readLong();
207            }
208    
209            @Override
210            public void writeExternal(ObjectOutput objectOutput)
211                    throws IOException {
212                    objectOutput.writeLong(mvccVersion);
213    
214                    if (uuid == null) {
215                            objectOutput.writeUTF(StringPool.BLANK);
216                    }
217                    else {
218                            objectOutput.writeUTF(uuid);
219                    }
220    
221                    objectOutput.writeLong(layoutFriendlyURLId);
222    
223                    objectOutput.writeLong(groupId);
224    
225                    objectOutput.writeLong(companyId);
226    
227                    objectOutput.writeLong(userId);
228    
229                    if (userName == null) {
230                            objectOutput.writeUTF(StringPool.BLANK);
231                    }
232                    else {
233                            objectOutput.writeUTF(userName);
234                    }
235    
236                    objectOutput.writeLong(createDate);
237                    objectOutput.writeLong(modifiedDate);
238    
239                    objectOutput.writeLong(plid);
240    
241                    objectOutput.writeBoolean(privateLayout);
242    
243                    if (friendlyURL == null) {
244                            objectOutput.writeUTF(StringPool.BLANK);
245                    }
246                    else {
247                            objectOutput.writeUTF(friendlyURL);
248                    }
249    
250                    if (languageId == null) {
251                            objectOutput.writeUTF(StringPool.BLANK);
252                    }
253                    else {
254                            objectOutput.writeUTF(languageId);
255                    }
256    
257                    objectOutput.writeLong(lastPublishDate);
258            }
259    
260            public long mvccVersion;
261            public String uuid;
262            public long layoutFriendlyURLId;
263            public long groupId;
264            public long companyId;
265            public long userId;
266            public String userName;
267            public long createDate;
268            public long modifiedDate;
269            public long plid;
270            public boolean privateLayout;
271            public String friendlyURL;
272            public String languageId;
273            public long lastPublishDate;
274    }