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.PollsChoice;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    /**
029     * The cache model class for representing PollsChoice in entity cache.
030     *
031     * @author Brian Wing Shun Chan
032     * @see PollsChoice
033     * @generated
034     */
035    public class PollsChoiceCacheModel implements CacheModel<PollsChoice>,
036            Externalizable {
037            @Override
038            public String toString() {
039                    StringBundler sb = new StringBundler(11);
040    
041                    sb.append("{uuid=");
042                    sb.append(uuid);
043                    sb.append(", choiceId=");
044                    sb.append(choiceId);
045                    sb.append(", questionId=");
046                    sb.append(questionId);
047                    sb.append(", name=");
048                    sb.append(name);
049                    sb.append(", description=");
050                    sb.append(description);
051                    sb.append("}");
052    
053                    return sb.toString();
054            }
055    
056            public PollsChoice toEntityModel() {
057                    PollsChoiceImpl pollsChoiceImpl = new PollsChoiceImpl();
058    
059                    if (uuid == null) {
060                            pollsChoiceImpl.setUuid(StringPool.BLANK);
061                    }
062                    else {
063                            pollsChoiceImpl.setUuid(uuid);
064                    }
065    
066                    pollsChoiceImpl.setChoiceId(choiceId);
067                    pollsChoiceImpl.setQuestionId(questionId);
068    
069                    if (name == null) {
070                            pollsChoiceImpl.setName(StringPool.BLANK);
071                    }
072                    else {
073                            pollsChoiceImpl.setName(name);
074                    }
075    
076                    if (description == null) {
077                            pollsChoiceImpl.setDescription(StringPool.BLANK);
078                    }
079                    else {
080                            pollsChoiceImpl.setDescription(description);
081                    }
082    
083                    pollsChoiceImpl.resetOriginalValues();
084    
085                    return pollsChoiceImpl;
086            }
087    
088            public void readExternal(ObjectInput objectInput) throws IOException {
089                    uuid = objectInput.readUTF();
090                    choiceId = objectInput.readLong();
091                    questionId = objectInput.readLong();
092                    name = objectInput.readUTF();
093                    description = objectInput.readUTF();
094            }
095    
096            public void writeExternal(ObjectOutput objectOutput)
097                    throws IOException {
098                    if (uuid == null) {
099                            objectOutput.writeUTF(StringPool.BLANK);
100                    }
101                    else {
102                            objectOutput.writeUTF(uuid);
103                    }
104    
105                    objectOutput.writeLong(choiceId);
106                    objectOutput.writeLong(questionId);
107    
108                    if (name == null) {
109                            objectOutput.writeUTF(StringPool.BLANK);
110                    }
111                    else {
112                            objectOutput.writeUTF(name);
113                    }
114    
115                    if (description == null) {
116                            objectOutput.writeUTF(StringPool.BLANK);
117                    }
118                    else {
119                            objectOutput.writeUTF(description);
120                    }
121            }
122    
123            public String uuid;
124            public long choiceId;
125            public long questionId;
126            public String name;
127            public String description;
128    }