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.ratings.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.ratings.model.RatingsEntry;
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 RatingsEntry in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see RatingsEntry
035     * @generated
036     */
037    public class RatingsEntryCacheModel implements CacheModel<RatingsEntry>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(19);
042    
043                    sb.append("{entryId=");
044                    sb.append(entryId);
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(", classNameId=");
056                    sb.append(classNameId);
057                    sb.append(", classPK=");
058                    sb.append(classPK);
059                    sb.append(", score=");
060                    sb.append(score);
061                    sb.append("}");
062    
063                    return sb.toString();
064            }
065    
066            @Override
067            public RatingsEntry toEntityModel() {
068                    RatingsEntryImpl ratingsEntryImpl = new RatingsEntryImpl();
069    
070                    ratingsEntryImpl.setEntryId(entryId);
071                    ratingsEntryImpl.setCompanyId(companyId);
072                    ratingsEntryImpl.setUserId(userId);
073    
074                    if (userName == null) {
075                            ratingsEntryImpl.setUserName(StringPool.BLANK);
076                    }
077                    else {
078                            ratingsEntryImpl.setUserName(userName);
079                    }
080    
081                    if (createDate == Long.MIN_VALUE) {
082                            ratingsEntryImpl.setCreateDate(null);
083                    }
084                    else {
085                            ratingsEntryImpl.setCreateDate(new Date(createDate));
086                    }
087    
088                    if (modifiedDate == Long.MIN_VALUE) {
089                            ratingsEntryImpl.setModifiedDate(null);
090                    }
091                    else {
092                            ratingsEntryImpl.setModifiedDate(new Date(modifiedDate));
093                    }
094    
095                    ratingsEntryImpl.setClassNameId(classNameId);
096                    ratingsEntryImpl.setClassPK(classPK);
097                    ratingsEntryImpl.setScore(score);
098    
099                    ratingsEntryImpl.resetOriginalValues();
100    
101                    return ratingsEntryImpl;
102            }
103    
104            @Override
105            public void readExternal(ObjectInput objectInput) throws IOException {
106                    entryId = objectInput.readLong();
107                    companyId = objectInput.readLong();
108                    userId = objectInput.readLong();
109                    userName = objectInput.readUTF();
110                    createDate = objectInput.readLong();
111                    modifiedDate = objectInput.readLong();
112                    classNameId = objectInput.readLong();
113                    classPK = objectInput.readLong();
114                    score = objectInput.readDouble();
115            }
116    
117            @Override
118            public void writeExternal(ObjectOutput objectOutput)
119                    throws IOException {
120                    objectOutput.writeLong(entryId);
121                    objectOutput.writeLong(companyId);
122                    objectOutput.writeLong(userId);
123    
124                    if (userName == null) {
125                            objectOutput.writeUTF(StringPool.BLANK);
126                    }
127                    else {
128                            objectOutput.writeUTF(userName);
129                    }
130    
131                    objectOutput.writeLong(createDate);
132                    objectOutput.writeLong(modifiedDate);
133                    objectOutput.writeLong(classNameId);
134                    objectOutput.writeLong(classPK);
135                    objectOutput.writeDouble(score);
136            }
137    
138            public long entryId;
139            public long companyId;
140            public long userId;
141            public String userName;
142            public long createDate;
143            public long modifiedDate;
144            public long classNameId;
145            public long classPK;
146            public double score;
147    }