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