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.ratings.model.impl;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.model.CacheModel;
019    
020    import com.liferay.portlet.ratings.model.RatingsStats;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    /**
028     * The cache model class for representing RatingsStats in entity cache.
029     *
030     * @author Brian Wing Shun Chan
031     * @see RatingsStats
032     * @generated
033     */
034    public class RatingsStatsCacheModel implements CacheModel<RatingsStats>,
035            Externalizable {
036            @Override
037            public String toString() {
038                    StringBundler sb = new StringBundler(13);
039    
040                    sb.append("{statsId=");
041                    sb.append(statsId);
042                    sb.append(", classNameId=");
043                    sb.append(classNameId);
044                    sb.append(", classPK=");
045                    sb.append(classPK);
046                    sb.append(", totalEntries=");
047                    sb.append(totalEntries);
048                    sb.append(", totalScore=");
049                    sb.append(totalScore);
050                    sb.append(", averageScore=");
051                    sb.append(averageScore);
052                    sb.append("}");
053    
054                    return sb.toString();
055            }
056    
057            public RatingsStats toEntityModel() {
058                    RatingsStatsImpl ratingsStatsImpl = new RatingsStatsImpl();
059    
060                    ratingsStatsImpl.setStatsId(statsId);
061                    ratingsStatsImpl.setClassNameId(classNameId);
062                    ratingsStatsImpl.setClassPK(classPK);
063                    ratingsStatsImpl.setTotalEntries(totalEntries);
064                    ratingsStatsImpl.setTotalScore(totalScore);
065                    ratingsStatsImpl.setAverageScore(averageScore);
066    
067                    ratingsStatsImpl.resetOriginalValues();
068    
069                    return ratingsStatsImpl;
070            }
071    
072            public void readExternal(ObjectInput objectInput) throws IOException {
073                    statsId = objectInput.readLong();
074                    classNameId = objectInput.readLong();
075                    classPK = objectInput.readLong();
076                    totalEntries = objectInput.readInt();
077                    totalScore = objectInput.readDouble();
078                    averageScore = objectInput.readDouble();
079            }
080    
081            public void writeExternal(ObjectOutput objectOutput)
082                    throws IOException {
083                    objectOutput.writeLong(statsId);
084                    objectOutput.writeLong(classNameId);
085                    objectOutput.writeLong(classPK);
086                    objectOutput.writeInt(totalEntries);
087                    objectOutput.writeDouble(totalScore);
088                    objectOutput.writeDouble(averageScore);
089            }
090    
091            public long statsId;
092            public long classNameId;
093            public long classPK;
094            public int totalEntries;
095            public double totalScore;
096            public double averageScore;
097    }