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.PollsQuestion;
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 PollsQuestion in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see PollsQuestion
035     * @generated
036     */
037    public class PollsQuestionCacheModel implements CacheModel<PollsQuestion>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(25);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", questionId=");
046                    sb.append(questionId);
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(", title=");
060                    sb.append(title);
061                    sb.append(", description=");
062                    sb.append(description);
063                    sb.append(", expirationDate=");
064                    sb.append(expirationDate);
065                    sb.append(", lastVoteDate=");
066                    sb.append(lastVoteDate);
067                    sb.append("}");
068    
069                    return sb.toString();
070            }
071    
072            public PollsQuestion toEntityModel() {
073                    PollsQuestionImpl pollsQuestionImpl = new PollsQuestionImpl();
074    
075                    if (uuid == null) {
076                            pollsQuestionImpl.setUuid(StringPool.BLANK);
077                    }
078                    else {
079                            pollsQuestionImpl.setUuid(uuid);
080                    }
081    
082                    pollsQuestionImpl.setQuestionId(questionId);
083                    pollsQuestionImpl.setGroupId(groupId);
084                    pollsQuestionImpl.setCompanyId(companyId);
085                    pollsQuestionImpl.setUserId(userId);
086    
087                    if (userName == null) {
088                            pollsQuestionImpl.setUserName(StringPool.BLANK);
089                    }
090                    else {
091                            pollsQuestionImpl.setUserName(userName);
092                    }
093    
094                    if (createDate == Long.MIN_VALUE) {
095                            pollsQuestionImpl.setCreateDate(null);
096                    }
097                    else {
098                            pollsQuestionImpl.setCreateDate(new Date(createDate));
099                    }
100    
101                    if (modifiedDate == Long.MIN_VALUE) {
102                            pollsQuestionImpl.setModifiedDate(null);
103                    }
104                    else {
105                            pollsQuestionImpl.setModifiedDate(new Date(modifiedDate));
106                    }
107    
108                    if (title == null) {
109                            pollsQuestionImpl.setTitle(StringPool.BLANK);
110                    }
111                    else {
112                            pollsQuestionImpl.setTitle(title);
113                    }
114    
115                    if (description == null) {
116                            pollsQuestionImpl.setDescription(StringPool.BLANK);
117                    }
118                    else {
119                            pollsQuestionImpl.setDescription(description);
120                    }
121    
122                    if (expirationDate == Long.MIN_VALUE) {
123                            pollsQuestionImpl.setExpirationDate(null);
124                    }
125                    else {
126                            pollsQuestionImpl.setExpirationDate(new Date(expirationDate));
127                    }
128    
129                    if (lastVoteDate == Long.MIN_VALUE) {
130                            pollsQuestionImpl.setLastVoteDate(null);
131                    }
132                    else {
133                            pollsQuestionImpl.setLastVoteDate(new Date(lastVoteDate));
134                    }
135    
136                    pollsQuestionImpl.resetOriginalValues();
137    
138                    return pollsQuestionImpl;
139            }
140    
141            public void readExternal(ObjectInput objectInput) throws IOException {
142                    uuid = objectInput.readUTF();
143                    questionId = objectInput.readLong();
144                    groupId = objectInput.readLong();
145                    companyId = objectInput.readLong();
146                    userId = objectInput.readLong();
147                    userName = objectInput.readUTF();
148                    createDate = objectInput.readLong();
149                    modifiedDate = objectInput.readLong();
150                    title = objectInput.readUTF();
151                    description = objectInput.readUTF();
152                    expirationDate = objectInput.readLong();
153                    lastVoteDate = objectInput.readLong();
154            }
155    
156            public void writeExternal(ObjectOutput objectOutput)
157                    throws IOException {
158                    if (uuid == null) {
159                            objectOutput.writeUTF(StringPool.BLANK);
160                    }
161                    else {
162                            objectOutput.writeUTF(uuid);
163                    }
164    
165                    objectOutput.writeLong(questionId);
166                    objectOutput.writeLong(groupId);
167                    objectOutput.writeLong(companyId);
168                    objectOutput.writeLong(userId);
169    
170                    if (userName == null) {
171                            objectOutput.writeUTF(StringPool.BLANK);
172                    }
173                    else {
174                            objectOutput.writeUTF(userName);
175                    }
176    
177                    objectOutput.writeLong(createDate);
178                    objectOutput.writeLong(modifiedDate);
179    
180                    if (title == null) {
181                            objectOutput.writeUTF(StringPool.BLANK);
182                    }
183                    else {
184                            objectOutput.writeUTF(title);
185                    }
186    
187                    if (description == null) {
188                            objectOutput.writeUTF(StringPool.BLANK);
189                    }
190                    else {
191                            objectOutput.writeUTF(description);
192                    }
193    
194                    objectOutput.writeLong(expirationDate);
195                    objectOutput.writeLong(lastVoteDate);
196            }
197    
198            public String uuid;
199            public long questionId;
200            public long groupId;
201            public long companyId;
202            public long userId;
203            public String userName;
204            public long createDate;
205            public long modifiedDate;
206            public String title;
207            public String description;
208            public long expirationDate;
209            public long lastVoteDate;
210    }