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.EmailAddress;
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 EmailAddress in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see EmailAddress
038     * @generated
039     */
040    @ProviderType
041    public class EmailAddressCacheModel implements CacheModel<EmailAddress>,
042            Externalizable, MVCCModel {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof EmailAddressCacheModel)) {
050                            return false;
051                    }
052    
053                    EmailAddressCacheModel emailAddressCacheModel = (EmailAddressCacheModel)obj;
054    
055                    if ((emailAddressId == emailAddressCacheModel.emailAddressId) &&
056                                    (mvccVersion == emailAddressCacheModel.mvccVersion)) {
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hashCode = HashUtil.hash(0, emailAddressId);
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(", emailAddressId=");
089                    sb.append(emailAddressId);
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(", address=");
105                    sb.append(address);
106                    sb.append(", typeId=");
107                    sb.append(typeId);
108                    sb.append(", primary=");
109                    sb.append(primary);
110                    sb.append("}");
111    
112                    return sb.toString();
113            }
114    
115            @Override
116            public EmailAddress toEntityModel() {
117                    EmailAddressImpl emailAddressImpl = new EmailAddressImpl();
118    
119                    emailAddressImpl.setMvccVersion(mvccVersion);
120    
121                    if (uuid == null) {
122                            emailAddressImpl.setUuid(StringPool.BLANK);
123                    }
124                    else {
125                            emailAddressImpl.setUuid(uuid);
126                    }
127    
128                    emailAddressImpl.setEmailAddressId(emailAddressId);
129                    emailAddressImpl.setCompanyId(companyId);
130                    emailAddressImpl.setUserId(userId);
131    
132                    if (userName == null) {
133                            emailAddressImpl.setUserName(StringPool.BLANK);
134                    }
135                    else {
136                            emailAddressImpl.setUserName(userName);
137                    }
138    
139                    if (createDate == Long.MIN_VALUE) {
140                            emailAddressImpl.setCreateDate(null);
141                    }
142                    else {
143                            emailAddressImpl.setCreateDate(new Date(createDate));
144                    }
145    
146                    if (modifiedDate == Long.MIN_VALUE) {
147                            emailAddressImpl.setModifiedDate(null);
148                    }
149                    else {
150                            emailAddressImpl.setModifiedDate(new Date(modifiedDate));
151                    }
152    
153                    emailAddressImpl.setClassNameId(classNameId);
154                    emailAddressImpl.setClassPK(classPK);
155    
156                    if (address == null) {
157                            emailAddressImpl.setAddress(StringPool.BLANK);
158                    }
159                    else {
160                            emailAddressImpl.setAddress(address);
161                    }
162    
163                    emailAddressImpl.setTypeId(typeId);
164                    emailAddressImpl.setPrimary(primary);
165    
166                    emailAddressImpl.resetOriginalValues();
167    
168                    return emailAddressImpl;
169            }
170    
171            @Override
172            public void readExternal(ObjectInput objectInput) throws IOException {
173                    mvccVersion = objectInput.readLong();
174                    uuid = objectInput.readUTF();
175                    emailAddressId = objectInput.readLong();
176                    companyId = objectInput.readLong();
177                    userId = objectInput.readLong();
178                    userName = objectInput.readUTF();
179                    createDate = objectInput.readLong();
180                    modifiedDate = objectInput.readLong();
181                    classNameId = objectInput.readLong();
182                    classPK = objectInput.readLong();
183                    address = objectInput.readUTF();
184                    typeId = objectInput.readLong();
185                    primary = objectInput.readBoolean();
186            }
187    
188            @Override
189            public void writeExternal(ObjectOutput objectOutput)
190                    throws IOException {
191                    objectOutput.writeLong(mvccVersion);
192    
193                    if (uuid == null) {
194                            objectOutput.writeUTF(StringPool.BLANK);
195                    }
196                    else {
197                            objectOutput.writeUTF(uuid);
198                    }
199    
200                    objectOutput.writeLong(emailAddressId);
201                    objectOutput.writeLong(companyId);
202                    objectOutput.writeLong(userId);
203    
204                    if (userName == null) {
205                            objectOutput.writeUTF(StringPool.BLANK);
206                    }
207                    else {
208                            objectOutput.writeUTF(userName);
209                    }
210    
211                    objectOutput.writeLong(createDate);
212                    objectOutput.writeLong(modifiedDate);
213                    objectOutput.writeLong(classNameId);
214                    objectOutput.writeLong(classPK);
215    
216                    if (address == null) {
217                            objectOutput.writeUTF(StringPool.BLANK);
218                    }
219                    else {
220                            objectOutput.writeUTF(address);
221                    }
222    
223                    objectOutput.writeLong(typeId);
224                    objectOutput.writeBoolean(primary);
225            }
226    
227            public long mvccVersion;
228            public String uuid;
229            public long emailAddressId;
230            public long companyId;
231            public long userId;
232            public String userName;
233            public long createDate;
234            public long modifiedDate;
235            public long classNameId;
236            public long classPK;
237            public String address;
238            public long typeId;
239            public boolean primary;
240    }