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.PollsVote;
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 PollsVote in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see PollsVote
035     * @generated
036     */
037    public class PollsVoteCacheModel implements CacheModel<PollsVote>,
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(", voteId=");
046                    sb.append(voteId);
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(", choiceId=");
062                    sb.append(choiceId);
063                    sb.append(", voteDate=");
064                    sb.append(voteDate);
065                    sb.append("}");
066    
067                    return sb.toString();
068            }
069    
070            public PollsVote toEntityModel() {
071                    PollsVoteImpl pollsVoteImpl = new PollsVoteImpl();
072    
073                    if (uuid == null) {
074                            pollsVoteImpl.setUuid(StringPool.BLANK);
075                    }
076                    else {
077                            pollsVoteImpl.setUuid(uuid);
078                    }
079    
080                    pollsVoteImpl.setVoteId(voteId);
081                    pollsVoteImpl.setGroupId(groupId);
082                    pollsVoteImpl.setCompanyId(companyId);
083                    pollsVoteImpl.setUserId(userId);
084    
085                    if (userName == null) {
086                            pollsVoteImpl.setUserName(StringPool.BLANK);
087                    }
088                    else {
089                            pollsVoteImpl.setUserName(userName);
090                    }
091    
092                    if (createDate == Long.MIN_VALUE) {
093                            pollsVoteImpl.setCreateDate(null);
094                    }
095                    else {
096                            pollsVoteImpl.setCreateDate(new Date(createDate));
097                    }
098    
099                    if (modifiedDate == Long.MIN_VALUE) {
100                            pollsVoteImpl.setModifiedDate(null);
101                    }
102                    else {
103                            pollsVoteImpl.setModifiedDate(new Date(modifiedDate));
104                    }
105    
106                    pollsVoteImpl.setQuestionId(questionId);
107                    pollsVoteImpl.setChoiceId(choiceId);
108    
109                    if (voteDate == Long.MIN_VALUE) {
110                            pollsVoteImpl.setVoteDate(null);
111                    }
112                    else {
113                            pollsVoteImpl.setVoteDate(new Date(voteDate));
114                    }
115    
116                    pollsVoteImpl.resetOriginalValues();
117    
118                    return pollsVoteImpl;
119            }
120    
121            public void readExternal(ObjectInput objectInput) throws IOException {
122                    uuid = objectInput.readUTF();
123                    voteId = objectInput.readLong();
124                    groupId = objectInput.readLong();
125                    companyId = objectInput.readLong();
126                    userId = objectInput.readLong();
127                    userName = objectInput.readUTF();
128                    createDate = objectInput.readLong();
129                    modifiedDate = objectInput.readLong();
130                    questionId = objectInput.readLong();
131                    choiceId = objectInput.readLong();
132                    voteDate = objectInput.readLong();
133            }
134    
135            public void writeExternal(ObjectOutput objectOutput)
136                    throws IOException {
137                    if (uuid == null) {
138                            objectOutput.writeUTF(StringPool.BLANK);
139                    }
140                    else {
141                            objectOutput.writeUTF(uuid);
142                    }
143    
144                    objectOutput.writeLong(voteId);
145                    objectOutput.writeLong(groupId);
146                    objectOutput.writeLong(companyId);
147                    objectOutput.writeLong(userId);
148    
149                    if (userName == null) {
150                            objectOutput.writeUTF(StringPool.BLANK);
151                    }
152                    else {
153                            objectOutput.writeUTF(userName);
154                    }
155    
156                    objectOutput.writeLong(createDate);
157                    objectOutput.writeLong(modifiedDate);
158                    objectOutput.writeLong(questionId);
159                    objectOutput.writeLong(choiceId);
160                    objectOutput.writeLong(voteDate);
161            }
162    
163            public String uuid;
164            public long voteId;
165            public long groupId;
166            public long companyId;
167            public long userId;
168            public String userName;
169            public long createDate;
170            public long modifiedDate;
171            public long questionId;
172            public long choiceId;
173            public long voteDate;
174    }