001    /**
002     * Copyright (c) 2000-2012 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(19);
042    
043                    sb.append("{voteId=");
044                    sb.append(voteId);
045                    sb.append(", companyId=");
046                    sb.append(companyId);
047                    sb.append(", userId=");
048                    sb.append(userId);
049                    sb.append(", userName=");
050                    sb.append(userName);
051                    sb.append(", createDate=");
052                    sb.append(createDate);
053                    sb.append(", modifiedDate=");
054                    sb.append(modifiedDate);
055                    sb.append(", questionId=");
056                    sb.append(questionId);
057                    sb.append(", choiceId=");
058                    sb.append(choiceId);
059                    sb.append(", voteDate=");
060                    sb.append(voteDate);
061                    sb.append("}");
062    
063                    return sb.toString();
064            }
065    
066            public PollsVote toEntityModel() {
067                    PollsVoteImpl pollsVoteImpl = new PollsVoteImpl();
068    
069                    pollsVoteImpl.setVoteId(voteId);
070                    pollsVoteImpl.setCompanyId(companyId);
071                    pollsVoteImpl.setUserId(userId);
072    
073                    if (userName == null) {
074                            pollsVoteImpl.setUserName(StringPool.BLANK);
075                    }
076                    else {
077                            pollsVoteImpl.setUserName(userName);
078                    }
079    
080                    if (createDate == Long.MIN_VALUE) {
081                            pollsVoteImpl.setCreateDate(null);
082                    }
083                    else {
084                            pollsVoteImpl.setCreateDate(new Date(createDate));
085                    }
086    
087                    if (modifiedDate == Long.MIN_VALUE) {
088                            pollsVoteImpl.setModifiedDate(null);
089                    }
090                    else {
091                            pollsVoteImpl.setModifiedDate(new Date(modifiedDate));
092                    }
093    
094                    pollsVoteImpl.setQuestionId(questionId);
095                    pollsVoteImpl.setChoiceId(choiceId);
096    
097                    if (voteDate == Long.MIN_VALUE) {
098                            pollsVoteImpl.setVoteDate(null);
099                    }
100                    else {
101                            pollsVoteImpl.setVoteDate(new Date(voteDate));
102                    }
103    
104                    pollsVoteImpl.resetOriginalValues();
105    
106                    return pollsVoteImpl;
107            }
108    
109            public void readExternal(ObjectInput objectInput) throws IOException {
110                    voteId = objectInput.readLong();
111                    companyId = objectInput.readLong();
112                    userId = objectInput.readLong();
113                    userName = objectInput.readUTF();
114                    createDate = objectInput.readLong();
115                    modifiedDate = objectInput.readLong();
116                    questionId = objectInput.readLong();
117                    choiceId = objectInput.readLong();
118                    voteDate = objectInput.readLong();
119            }
120    
121            public void writeExternal(ObjectOutput objectOutput)
122                    throws IOException {
123                    objectOutput.writeLong(voteId);
124                    objectOutput.writeLong(companyId);
125                    objectOutput.writeLong(userId);
126    
127                    if (userName == null) {
128                            objectOutput.writeUTF(StringPool.BLANK);
129                    }
130                    else {
131                            objectOutput.writeUTF(userName);
132                    }
133    
134                    objectOutput.writeLong(createDate);
135                    objectOutput.writeLong(modifiedDate);
136                    objectOutput.writeLong(questionId);
137                    objectOutput.writeLong(choiceId);
138                    objectOutput.writeLong(voteDate);
139            }
140    
141            public long voteId;
142            public long companyId;
143            public long userId;
144            public String userName;
145            public long createDate;
146            public long modifiedDate;
147            public long questionId;
148            public long choiceId;
149            public long voteDate;
150    }