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.Phone;
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 Phone in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see Phone
038     * @generated
039     */
040    @ProviderType
041    public class PhoneCacheModel implements CacheModel<Phone>, Externalizable,
042            MVCCModel {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof PhoneCacheModel)) {
050                            return false;
051                    }
052    
053                    PhoneCacheModel phoneCacheModel = (PhoneCacheModel)obj;
054    
055                    if ((phoneId == phoneCacheModel.phoneId) &&
056                                    (mvccVersion == phoneCacheModel.mvccVersion)) {
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hashCode = HashUtil.hash(0, phoneId);
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(", phoneId=");
089                    sb.append(phoneId);
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(", number=");
105                    sb.append(number);
106                    sb.append(", extension=");
107                    sb.append(extension);
108                    sb.append(", typeId=");
109                    sb.append(typeId);
110                    sb.append(", primary=");
111                    sb.append(primary);
112                    sb.append("}");
113    
114                    return sb.toString();
115            }
116    
117            @Override
118            public Phone toEntityModel() {
119                    PhoneImpl phoneImpl = new PhoneImpl();
120    
121                    phoneImpl.setMvccVersion(mvccVersion);
122    
123                    if (uuid == null) {
124                            phoneImpl.setUuid(StringPool.BLANK);
125                    }
126                    else {
127                            phoneImpl.setUuid(uuid);
128                    }
129    
130                    phoneImpl.setPhoneId(phoneId);
131                    phoneImpl.setCompanyId(companyId);
132                    phoneImpl.setUserId(userId);
133    
134                    if (userName == null) {
135                            phoneImpl.setUserName(StringPool.BLANK);
136                    }
137                    else {
138                            phoneImpl.setUserName(userName);
139                    }
140    
141                    if (createDate == Long.MIN_VALUE) {
142                            phoneImpl.setCreateDate(null);
143                    }
144                    else {
145                            phoneImpl.setCreateDate(new Date(createDate));
146                    }
147    
148                    if (modifiedDate == Long.MIN_VALUE) {
149                            phoneImpl.setModifiedDate(null);
150                    }
151                    else {
152                            phoneImpl.setModifiedDate(new Date(modifiedDate));
153                    }
154    
155                    phoneImpl.setClassNameId(classNameId);
156                    phoneImpl.setClassPK(classPK);
157    
158                    if (number == null) {
159                            phoneImpl.setNumber(StringPool.BLANK);
160                    }
161                    else {
162                            phoneImpl.setNumber(number);
163                    }
164    
165                    if (extension == null) {
166                            phoneImpl.setExtension(StringPool.BLANK);
167                    }
168                    else {
169                            phoneImpl.setExtension(extension);
170                    }
171    
172                    phoneImpl.setTypeId(typeId);
173                    phoneImpl.setPrimary(primary);
174    
175                    phoneImpl.resetOriginalValues();
176    
177                    return phoneImpl;
178            }
179    
180            @Override
181            public void readExternal(ObjectInput objectInput) throws IOException {
182                    mvccVersion = objectInput.readLong();
183                    uuid = objectInput.readUTF();
184                    phoneId = 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                    number = objectInput.readUTF();
193                    extension = objectInput.readUTF();
194                    typeId = objectInput.readLong();
195                    primary = objectInput.readBoolean();
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(phoneId);
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 (number == null) {
227                            objectOutput.writeUTF(StringPool.BLANK);
228                    }
229                    else {
230                            objectOutput.writeUTF(number);
231                    }
232    
233                    if (extension == null) {
234                            objectOutput.writeUTF(StringPool.BLANK);
235                    }
236                    else {
237                            objectOutput.writeUTF(extension);
238                    }
239    
240                    objectOutput.writeLong(typeId);
241                    objectOutput.writeBoolean(primary);
242            }
243    
244            public long mvccVersion;
245            public String uuid;
246            public long phoneId;
247            public long companyId;
248            public long userId;
249            public String userName;
250            public long createDate;
251            public long modifiedDate;
252            public long classNameId;
253            public long classPK;
254            public String number;
255            public String extension;
256            public long typeId;
257            public boolean primary;
258    }