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.model.CacheModel;
020    import com.liferay.portal.kernel.util.HashUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    
023    import com.liferay.ratings.kernel.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    
108                    companyId = objectInput.readLong();
109    
110                    classNameId = objectInput.readLong();
111    
112                    classPK = objectInput.readLong();
113    
114                    totalEntries = objectInput.readInt();
115    
116                    totalScore = objectInput.readDouble();
117    
118                    averageScore = objectInput.readDouble();
119            }
120    
121            @Override
122            public void writeExternal(ObjectOutput objectOutput)
123                    throws IOException {
124                    objectOutput.writeLong(statsId);
125    
126                    objectOutput.writeLong(companyId);
127    
128                    objectOutput.writeLong(classNameId);
129    
130                    objectOutput.writeLong(classPK);
131    
132                    objectOutput.writeInt(totalEntries);
133    
134                    objectOutput.writeDouble(totalScore);
135    
136                    objectOutput.writeDouble(averageScore);
137            }
138    
139            public long statsId;
140            public long companyId;
141            public long classNameId;
142            public long classPK;
143            public int totalEntries;
144            public double totalScore;
145            public double averageScore;
146    }