001    /**
002     * Copyright (c) 2000-present 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.ratings.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.CacheModel;
022    
023    import com.liferay.portlet.ratings.model.RatingsEntry;
024    
025    import java.io.Externalizable;
026    import java.io.IOException;
027    import java.io.ObjectInput;
028    import java.io.ObjectOutput;
029    
030    import java.util.Date;
031    
032    /**
033     * The cache model class for representing RatingsEntry in entity cache.
034     *
035     * @author Brian Wing Shun Chan
036     * @see RatingsEntry
037     * @generated
038     */
039    @ProviderType
040    public class RatingsEntryCacheModel implements CacheModel<RatingsEntry>,
041            Externalizable {
042            @Override
043            public String toString() {
044                    StringBundler sb = new StringBundler(21);
045    
046                    sb.append("{uuid=");
047                    sb.append(uuid);
048                    sb.append(", entryId=");
049                    sb.append(entryId);
050                    sb.append(", companyId=");
051                    sb.append(companyId);
052                    sb.append(", userId=");
053                    sb.append(userId);
054                    sb.append(", userName=");
055                    sb.append(userName);
056                    sb.append(", createDate=");
057                    sb.append(createDate);
058                    sb.append(", modifiedDate=");
059                    sb.append(modifiedDate);
060                    sb.append(", classNameId=");
061                    sb.append(classNameId);
062                    sb.append(", classPK=");
063                    sb.append(classPK);
064                    sb.append(", score=");
065                    sb.append(score);
066                    sb.append("}");
067    
068                    return sb.toString();
069            }
070    
071            @Override
072            public RatingsEntry toEntityModel() {
073                    RatingsEntryImpl ratingsEntryImpl = new RatingsEntryImpl();
074    
075                    if (uuid == null) {
076                            ratingsEntryImpl.setUuid(StringPool.BLANK);
077                    }
078                    else {
079                            ratingsEntryImpl.setUuid(uuid);
080                    }
081    
082                    ratingsEntryImpl.setEntryId(entryId);
083                    ratingsEntryImpl.setCompanyId(companyId);
084                    ratingsEntryImpl.setUserId(userId);
085    
086                    if (userName == null) {
087                            ratingsEntryImpl.setUserName(StringPool.BLANK);
088                    }
089                    else {
090                            ratingsEntryImpl.setUserName(userName);
091                    }
092    
093                    if (createDate == Long.MIN_VALUE) {
094                            ratingsEntryImpl.setCreateDate(null);
095                    }
096                    else {
097                            ratingsEntryImpl.setCreateDate(new Date(createDate));
098                    }
099    
100                    if (modifiedDate == Long.MIN_VALUE) {
101                            ratingsEntryImpl.setModifiedDate(null);
102                    }
103                    else {
104                            ratingsEntryImpl.setModifiedDate(new Date(modifiedDate));
105                    }
106    
107                    ratingsEntryImpl.setClassNameId(classNameId);
108                    ratingsEntryImpl.setClassPK(classPK);
109                    ratingsEntryImpl.setScore(score);
110    
111                    ratingsEntryImpl.resetOriginalValues();
112    
113                    return ratingsEntryImpl;
114            }
115    
116            @Override
117            public void readExternal(ObjectInput objectInput) throws IOException {
118                    uuid = objectInput.readUTF();
119                    entryId = objectInput.readLong();
120                    companyId = objectInput.readLong();
121                    userId = objectInput.readLong();
122                    userName = objectInput.readUTF();
123                    createDate = objectInput.readLong();
124                    modifiedDate = objectInput.readLong();
125                    classNameId = objectInput.readLong();
126                    classPK = objectInput.readLong();
127                    score = objectInput.readDouble();
128            }
129    
130            @Override
131            public void writeExternal(ObjectOutput objectOutput)
132                    throws IOException {
133                    if (uuid == null) {
134                            objectOutput.writeUTF(StringPool.BLANK);
135                    }
136                    else {
137                            objectOutput.writeUTF(uuid);
138                    }
139    
140                    objectOutput.writeLong(entryId);
141                    objectOutput.writeLong(companyId);
142                    objectOutput.writeLong(userId);
143    
144                    if (userName == null) {
145                            objectOutput.writeUTF(StringPool.BLANK);
146                    }
147                    else {
148                            objectOutput.writeUTF(userName);
149                    }
150    
151                    objectOutput.writeLong(createDate);
152                    objectOutput.writeLong(modifiedDate);
153                    objectOutput.writeLong(classNameId);
154                    objectOutput.writeLong(classPK);
155                    objectOutput.writeDouble(score);
156            }
157    
158            public String uuid;
159            public long entryId;
160            public long companyId;
161            public long userId;
162            public String userName;
163            public long createDate;
164            public long modifiedDate;
165            public long classNameId;
166            public long classPK;
167            public double score;
168    }