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.HashUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.model.CacheModel;
022    
023    import com.liferay.portlet.ratings.model.RatingsStats;
024    
025    import java.io.Externalizable;
026    import java.io.IOException;
027    import java.io.ObjectInput;
028    import java.io.ObjectOutput;
029    
030    /**
031     * The cache model class for representing RatingsStats in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see RatingsStats
035     * @generated
036     */
037    @ProviderType
038    public class RatingsStatsCacheModel implements CacheModel<RatingsStats>,
039            Externalizable {
040            @Override
041            public boolean equals(Object obj) {
042                    if (this == obj) {
043                            return true;
044                    }
045    
046                    if (!(obj instanceof RatingsStatsCacheModel)) {
047                            return false;
048                    }
049    
050                    RatingsStatsCacheModel ratingsStatsCacheModel = (RatingsStatsCacheModel)obj;
051    
052                    if (statsId == ratingsStatsCacheModel.statsId) {
053                            return true;
054                    }
055    
056                    return false;
057            }
058    
059            @Override
060            public int hashCode() {
061                    return HashUtil.hash(0, statsId);
062            }
063    
064            @Override
065            public String toString() {
066                    StringBundler sb = new StringBundler(13);
067    
068                    sb.append("{statsId=");
069                    sb.append(statsId);
070                    sb.append(", classNameId=");
071                    sb.append(classNameId);
072                    sb.append(", classPK=");
073                    sb.append(classPK);
074                    sb.append(", totalEntries=");
075                    sb.append(totalEntries);
076                    sb.append(", totalScore=");
077                    sb.append(totalScore);
078                    sb.append(", averageScore=");
079                    sb.append(averageScore);
080                    sb.append("}");
081    
082                    return sb.toString();
083            }
084    
085            @Override
086            public RatingsStats toEntityModel() {
087                    RatingsStatsImpl ratingsStatsImpl = new RatingsStatsImpl();
088    
089                    ratingsStatsImpl.setStatsId(statsId);
090                    ratingsStatsImpl.setClassNameId(classNameId);
091                    ratingsStatsImpl.setClassPK(classPK);
092                    ratingsStatsImpl.setTotalEntries(totalEntries);
093                    ratingsStatsImpl.setTotalScore(totalScore);
094                    ratingsStatsImpl.setAverageScore(averageScore);
095    
096                    ratingsStatsImpl.resetOriginalValues();
097    
098                    return ratingsStatsImpl;
099            }
100    
101            @Override
102            public void readExternal(ObjectInput objectInput) throws IOException {
103                    statsId = objectInput.readLong();
104                    classNameId = objectInput.readLong();
105                    classPK = objectInput.readLong();
106                    totalEntries = objectInput.readInt();
107                    totalScore = objectInput.readDouble();
108                    averageScore = objectInput.readDouble();
109            }
110    
111            @Override
112            public void writeExternal(ObjectOutput objectOutput)
113                    throws IOException {
114                    objectOutput.writeLong(statsId);
115                    objectOutput.writeLong(classNameId);
116                    objectOutput.writeLong(classPK);
117                    objectOutput.writeInt(totalEntries);
118                    objectOutput.writeDouble(totalScore);
119                    objectOutput.writeDouble(averageScore);
120            }
121    
122            public long statsId;
123            public long classNameId;
124            public long classPK;
125            public int totalEntries;
126            public double totalScore;
127            public double averageScore;
128    }