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(27);
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("}");
111    
112                    return sb.toString();
113            }
114    
115            @Override
116            public LayoutFriendlyURL toEntityModel() {
117                    LayoutFriendlyURLImpl layoutFriendlyURLImpl = new LayoutFriendlyURLImpl();
118    
119                    layoutFriendlyURLImpl.setMvccVersion(mvccVersion);
120    
121                    if (uuid == null) {
122                            layoutFriendlyURLImpl.setUuid(StringPool.BLANK);
123                    }
124                    else {
125                            layoutFriendlyURLImpl.setUuid(uuid);
126                    }
127    
128                    layoutFriendlyURLImpl.setLayoutFriendlyURLId(layoutFriendlyURLId);
129                    layoutFriendlyURLImpl.setGroupId(groupId);
130                    layoutFriendlyURLImpl.setCompanyId(companyId);
131                    layoutFriendlyURLImpl.setUserId(userId);
132    
133                    if (userName == null) {
134                            layoutFriendlyURLImpl.setUserName(StringPool.BLANK);
135                    }
136                    else {
137                            layoutFriendlyURLImpl.setUserName(userName);
138                    }
139    
140                    if (createDate == Long.MIN_VALUE) {
141                            layoutFriendlyURLImpl.setCreateDate(null);
142                    }
143                    else {
144                            layoutFriendlyURLImpl.setCreateDate(new Date(createDate));
145                    }
146    
147                    if (modifiedDate == Long.MIN_VALUE) {
148                            layoutFriendlyURLImpl.setModifiedDate(null);
149                    }
150                    else {
151                            layoutFriendlyURLImpl.setModifiedDate(new Date(modifiedDate));
152                    }
153    
154                    layoutFriendlyURLImpl.setPlid(plid);
155                    layoutFriendlyURLImpl.setPrivateLayout(privateLayout);
156    
157                    if (friendlyURL == null) {
158                            layoutFriendlyURLImpl.setFriendlyURL(StringPool.BLANK);
159                    }
160                    else {
161                            layoutFriendlyURLImpl.setFriendlyURL(friendlyURL);
162                    }
163    
164                    if (languageId == null) {
165                            layoutFriendlyURLImpl.setLanguageId(StringPool.BLANK);
166                    }
167                    else {
168                            layoutFriendlyURLImpl.setLanguageId(languageId);
169                    }
170    
171                    layoutFriendlyURLImpl.resetOriginalValues();
172    
173                    return layoutFriendlyURLImpl;
174            }
175    
176            @Override
177            public void readExternal(ObjectInput objectInput) throws IOException {
178                    mvccVersion = objectInput.readLong();
179                    uuid = objectInput.readUTF();
180                    layoutFriendlyURLId = objectInput.readLong();
181                    groupId = objectInput.readLong();
182                    companyId = objectInput.readLong();
183                    userId = objectInput.readLong();
184                    userName = objectInput.readUTF();
185                    createDate = objectInput.readLong();
186                    modifiedDate = objectInput.readLong();
187                    plid = objectInput.readLong();
188                    privateLayout = objectInput.readBoolean();
189                    friendlyURL = objectInput.readUTF();
190                    languageId = objectInput.readUTF();
191            }
192    
193            @Override
194            public void writeExternal(ObjectOutput objectOutput)
195                    throws IOException {
196                    objectOutput.writeLong(mvccVersion);
197    
198                    if (uuid == null) {
199                            objectOutput.writeUTF(StringPool.BLANK);
200                    }
201                    else {
202                            objectOutput.writeUTF(uuid);
203                    }
204    
205                    objectOutput.writeLong(layoutFriendlyURLId);
206                    objectOutput.writeLong(groupId);
207                    objectOutput.writeLong(companyId);
208                    objectOutput.writeLong(userId);
209    
210                    if (userName == null) {
211                            objectOutput.writeUTF(StringPool.BLANK);
212                    }
213                    else {
214                            objectOutput.writeUTF(userName);
215                    }
216    
217                    objectOutput.writeLong(createDate);
218                    objectOutput.writeLong(modifiedDate);
219                    objectOutput.writeLong(plid);
220                    objectOutput.writeBoolean(privateLayout);
221    
222                    if (friendlyURL == null) {
223                            objectOutput.writeUTF(StringPool.BLANK);
224                    }
225                    else {
226                            objectOutput.writeUTF(friendlyURL);
227                    }
228    
229                    if (languageId == null) {
230                            objectOutput.writeUTF(StringPool.BLANK);
231                    }
232                    else {
233                            objectOutput.writeUTF(languageId);
234                    }
235            }
236    
237            public long mvccVersion;
238            public String uuid;
239            public long layoutFriendlyURLId;
240            public long groupId;
241            public long companyId;
242            public long userId;
243            public String userName;
244            public long createDate;
245            public long modifiedDate;
246            public long plid;
247            public boolean privateLayout;
248            public String friendlyURL;
249            public String languageId;
250    }