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(25);
041    
042                    sb.append("{uuid=");
043                    sb.append(uuid);
044                    sb.append(", emailAddressId=");
045                    sb.append(emailAddressId);
046                    sb.append(", companyId=");
047                    sb.append(companyId);
048                    sb.append(", userId=");
049                    sb.append(userId);
050                    sb.append(", userName=");
051                    sb.append(userName);
052                    sb.append(", createDate=");
053                    sb.append(createDate);
054                    sb.append(", modifiedDate=");
055                    sb.append(modifiedDate);
056                    sb.append(", classNameId=");
057                    sb.append(classNameId);
058                    sb.append(", classPK=");
059                    sb.append(classPK);
060                    sb.append(", address=");
061                    sb.append(address);
062                    sb.append(", typeId=");
063                    sb.append(typeId);
064                    sb.append(", primary=");
065                    sb.append(primary);
066                    sb.append("}");
067    
068                    return sb.toString();
069            }
070    
071            @Override
072            public EmailAddress toEntityModel() {
073                    EmailAddressImpl emailAddressImpl = new EmailAddressImpl();
074    
075                    if (uuid == null) {
076                            emailAddressImpl.setUuid(StringPool.BLANK);
077                    }
078                    else {
079                            emailAddressImpl.setUuid(uuid);
080                    }
081    
082                    emailAddressImpl.setEmailAddressId(emailAddressId);
083                    emailAddressImpl.setCompanyId(companyId);
084                    emailAddressImpl.setUserId(userId);
085    
086                    if (userName == null) {
087                            emailAddressImpl.setUserName(StringPool.BLANK);
088                    }
089                    else {
090                            emailAddressImpl.setUserName(userName);
091                    }
092    
093                    if (createDate == Long.MIN_VALUE) {
094                            emailAddressImpl.setCreateDate(null);
095                    }
096                    else {
097                            emailAddressImpl.setCreateDate(new Date(createDate));
098                    }
099    
100                    if (modifiedDate == Long.MIN_VALUE) {
101                            emailAddressImpl.setModifiedDate(null);
102                    }
103                    else {
104                            emailAddressImpl.setModifiedDate(new Date(modifiedDate));
105                    }
106    
107                    emailAddressImpl.setClassNameId(classNameId);
108                    emailAddressImpl.setClassPK(classPK);
109    
110                    if (address == null) {
111                            emailAddressImpl.setAddress(StringPool.BLANK);
112                    }
113                    else {
114                            emailAddressImpl.setAddress(address);
115                    }
116    
117                    emailAddressImpl.setTypeId(typeId);
118                    emailAddressImpl.setPrimary(primary);
119    
120                    emailAddressImpl.resetOriginalValues();
121    
122                    return emailAddressImpl;
123            }
124    
125            @Override
126            public void readExternal(ObjectInput objectInput) throws IOException {
127                    uuid = objectInput.readUTF();
128                    emailAddressId = objectInput.readLong();
129                    companyId = objectInput.readLong();
130                    userId = objectInput.readLong();
131                    userName = objectInput.readUTF();
132                    createDate = objectInput.readLong();
133                    modifiedDate = objectInput.readLong();
134                    classNameId = objectInput.readLong();
135                    classPK = objectInput.readLong();
136                    address = objectInput.readUTF();
137                    typeId = objectInput.readInt();
138                    primary = objectInput.readBoolean();
139            }
140    
141            @Override
142            public void writeExternal(ObjectOutput objectOutput)
143                    throws IOException {
144                    if (uuid == null) {
145                            objectOutput.writeUTF(StringPool.BLANK);
146                    }
147                    else {
148                            objectOutput.writeUTF(uuid);
149                    }
150    
151                    objectOutput.writeLong(emailAddressId);
152                    objectOutput.writeLong(companyId);
153                    objectOutput.writeLong(userId);
154    
155                    if (userName == null) {
156                            objectOutput.writeUTF(StringPool.BLANK);
157                    }
158                    else {
159                            objectOutput.writeUTF(userName);
160                    }
161    
162                    objectOutput.writeLong(createDate);
163                    objectOutput.writeLong(modifiedDate);
164                    objectOutput.writeLong(classNameId);
165                    objectOutput.writeLong(classPK);
166    
167                    if (address == null) {
168                            objectOutput.writeUTF(StringPool.BLANK);
169                    }
170                    else {
171                            objectOutput.writeUTF(address);
172                    }
173    
174                    objectOutput.writeInt(typeId);
175                    objectOutput.writeBoolean(primary);
176            }
177    
178            public String uuid;
179            public long emailAddressId;
180            public long companyId;
181            public long userId;
182            public String userName;
183            public long createDate;
184            public long modifiedDate;
185            public long classNameId;
186            public long classPK;
187            public String address;
188            public int typeId;
189            public boolean primary;
190    }