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