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