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(15);
067    
068                    sb.append("{statsId=");
069                    sb.append(statsId);
070                    sb.append(", companyId=");
071                    sb.append(companyId);
072                    sb.append(", classNameId=");
073                    sb.append(classNameId);
074                    sb.append(", classPK=");
075                    sb.append(classPK);
076                    sb.append(", totalEntries=");
077                    sb.append(totalEntries);
078                    sb.append(", totalScore=");
079                    sb.append(totalScore);
080                    sb.append(", averageScore=");
081                    sb.append(averageScore);
082                    sb.append("}");
083    
084                    return sb.toString();
085            }
086    
087            @Override
088            public RatingsStats toEntityModel() {
089                    RatingsStatsImpl ratingsStatsImpl = new RatingsStatsImpl();
090    
091                    ratingsStatsImpl.setStatsId(statsId);
092                    ratingsStatsImpl.setCompanyId(companyId);
093                    ratingsStatsImpl.setClassNameId(classNameId);
094                    ratingsStatsImpl.setClassPK(classPK);
095                    ratingsStatsImpl.setTotalEntries(totalEntries);
096                    ratingsStatsImpl.setTotalScore(totalScore);
097                    ratingsStatsImpl.setAverageScore(averageScore);
098    
099                    ratingsStatsImpl.resetOriginalValues();
100    
101                    return ratingsStatsImpl;
102            }
103    
104            @Override
105            public void readExternal(ObjectInput objectInput) throws IOException {
106                    statsId = objectInput.readLong();
107                    companyId = objectInput.readLong();
108                    classNameId = objectInput.readLong();
109                    classPK = objectInput.readLong();
110                    totalEntries = objectInput.readInt();
111                    totalScore = objectInput.readDouble();
112                    averageScore = objectInput.readDouble();
113            }
114    
115            @Override
116            public void writeExternal(ObjectOutput objectOutput)
117                    throws IOException {
118                    objectOutput.writeLong(statsId);
119                    objectOutput.writeLong(companyId);
120                    objectOutput.writeLong(classNameId);
121                    objectOutput.writeLong(classPK);
122                    objectOutput.writeInt(totalEntries);
123                    objectOutput.writeDouble(totalScore);
124                    objectOutput.writeDouble(averageScore);
125            }
126    
127            public long statsId;
128            public long companyId;
129            public long classNameId;
130            public long classPK;
131            public int totalEntries;
132            public double totalScore;
133            public double averageScore;
134    }