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