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.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.CacheModel;
022    import com.liferay.portal.model.EmailAddress;
023    import com.liferay.portal.model.MVCCModel;
024    
025    import java.io.Externalizable;
026    import java.io.IOException;
027    import java.io.ObjectInput;
028    import java.io.ObjectOutput;
029    
030    import java.util.Date;
031    
032    /**
033     * The cache model class for representing EmailAddress in entity cache.
034     *
035     * @author Brian Wing Shun Chan
036     * @see EmailAddress
037     * @generated
038     */
039    @ProviderType
040    public class EmailAddressCacheModel implements CacheModel<EmailAddress>,
041            Externalizable, MVCCModel {
042            @Override
043            public long getMvccVersion() {
044                    return mvccVersion;
045            }
046    
047            @Override
048            public void setMvccVersion(long mvccVersion) {
049                    this.mvccVersion = mvccVersion;
050            }
051    
052            @Override
053            public String toString() {
054                    StringBundler sb = new StringBundler(27);
055    
056                    sb.append("{mvccVersion=");
057                    sb.append(mvccVersion);
058                    sb.append(", uuid=");
059                    sb.append(uuid);
060                    sb.append(", emailAddressId=");
061                    sb.append(emailAddressId);
062                    sb.append(", companyId=");
063                    sb.append(companyId);
064                    sb.append(", userId=");
065                    sb.append(userId);
066                    sb.append(", userName=");
067                    sb.append(userName);
068                    sb.append(", createDate=");
069                    sb.append(createDate);
070                    sb.append(", modifiedDate=");
071                    sb.append(modifiedDate);
072                    sb.append(", classNameId=");
073                    sb.append(classNameId);
074                    sb.append(", classPK=");
075                    sb.append(classPK);
076                    sb.append(", address=");
077                    sb.append(address);
078                    sb.append(", typeId=");
079                    sb.append(typeId);
080                    sb.append(", primary=");
081                    sb.append(primary);
082                    sb.append("}");
083    
084                    return sb.toString();
085            }
086    
087            @Override
088            public EmailAddress toEntityModel() {
089                    EmailAddressImpl emailAddressImpl = new EmailAddressImpl();
090    
091                    emailAddressImpl.setMvccVersion(mvccVersion);
092    
093                    if (uuid == null) {
094                            emailAddressImpl.setUuid(StringPool.BLANK);
095                    }
096                    else {
097                            emailAddressImpl.setUuid(uuid);
098                    }
099    
100                    emailAddressImpl.setEmailAddressId(emailAddressId);
101                    emailAddressImpl.setCompanyId(companyId);
102                    emailAddressImpl.setUserId(userId);
103    
104                    if (userName == null) {
105                            emailAddressImpl.setUserName(StringPool.BLANK);
106                    }
107                    else {
108                            emailAddressImpl.setUserName(userName);
109                    }
110    
111                    if (createDate == Long.MIN_VALUE) {
112                            emailAddressImpl.setCreateDate(null);
113                    }
114                    else {
115                            emailAddressImpl.setCreateDate(new Date(createDate));
116                    }
117    
118                    if (modifiedDate == Long.MIN_VALUE) {
119                            emailAddressImpl.setModifiedDate(null);
120                    }
121                    else {
122                            emailAddressImpl.setModifiedDate(new Date(modifiedDate));
123                    }
124    
125                    emailAddressImpl.setClassNameId(classNameId);
126                    emailAddressImpl.setClassPK(classPK);
127    
128                    if (address == null) {
129                            emailAddressImpl.setAddress(StringPool.BLANK);
130                    }
131                    else {
132                            emailAddressImpl.setAddress(address);
133                    }
134    
135                    emailAddressImpl.setTypeId(typeId);
136                    emailAddressImpl.setPrimary(primary);
137    
138                    emailAddressImpl.resetOriginalValues();
139    
140                    return emailAddressImpl;
141            }
142    
143            @Override
144            public void readExternal(ObjectInput objectInput) throws IOException {
145                    mvccVersion = objectInput.readLong();
146                    uuid = objectInput.readUTF();
147                    emailAddressId = objectInput.readLong();
148                    companyId = objectInput.readLong();
149                    userId = objectInput.readLong();
150                    userName = objectInput.readUTF();
151                    createDate = objectInput.readLong();
152                    modifiedDate = objectInput.readLong();
153                    classNameId = objectInput.readLong();
154                    classPK = objectInput.readLong();
155                    address = objectInput.readUTF();
156                    typeId = objectInput.readInt();
157                    primary = objectInput.readBoolean();
158            }
159    
160            @Override
161            public void writeExternal(ObjectOutput objectOutput)
162                    throws IOException {
163                    objectOutput.writeLong(mvccVersion);
164    
165                    if (uuid == null) {
166                            objectOutput.writeUTF(StringPool.BLANK);
167                    }
168                    else {
169                            objectOutput.writeUTF(uuid);
170                    }
171    
172                    objectOutput.writeLong(emailAddressId);
173                    objectOutput.writeLong(companyId);
174                    objectOutput.writeLong(userId);
175    
176                    if (userName == null) {
177                            objectOutput.writeUTF(StringPool.BLANK);
178                    }
179                    else {
180                            objectOutput.writeUTF(userName);
181                    }
182    
183                    objectOutput.writeLong(createDate);
184                    objectOutput.writeLong(modifiedDate);
185                    objectOutput.writeLong(classNameId);
186                    objectOutput.writeLong(classPK);
187    
188                    if (address == null) {
189                            objectOutput.writeUTF(StringPool.BLANK);
190                    }
191                    else {
192                            objectOutput.writeUTF(address);
193                    }
194    
195                    objectOutput.writeInt(typeId);
196                    objectOutput.writeBoolean(primary);
197            }
198    
199            public long mvccVersion;
200            public String uuid;
201            public long emailAddressId;
202            public long companyId;
203            public long userId;
204            public String userName;
205            public long createDate;
206            public long modifiedDate;
207            public long classNameId;
208            public long classPK;
209            public String address;
210            public int typeId;
211            public boolean primary;
212    }