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.blogs.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.model.CacheModel;
021    
022    import com.liferay.portlet.blogs.model.BlogsStatsUser;
023    
024    import java.io.Externalizable;
025    import java.io.IOException;
026    import java.io.ObjectInput;
027    import java.io.ObjectOutput;
028    
029    import java.util.Date;
030    
031    /**
032     * The cache model class for representing BlogsStatsUser in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see BlogsStatsUser
036     * @generated
037     */
038    @ProviderType
039    public class BlogsStatsUserCacheModel implements CacheModel<BlogsStatsUser>,
040            Externalizable {
041            @Override
042            public String toString() {
043                    StringBundler sb = new StringBundler(19);
044    
045                    sb.append("{statsUserId=");
046                    sb.append(statsUserId);
047                    sb.append(", groupId=");
048                    sb.append(groupId);
049                    sb.append(", companyId=");
050                    sb.append(companyId);
051                    sb.append(", userId=");
052                    sb.append(userId);
053                    sb.append(", entryCount=");
054                    sb.append(entryCount);
055                    sb.append(", lastPostDate=");
056                    sb.append(lastPostDate);
057                    sb.append(", ratingsTotalEntries=");
058                    sb.append(ratingsTotalEntries);
059                    sb.append(", ratingsTotalScore=");
060                    sb.append(ratingsTotalScore);
061                    sb.append(", ratingsAverageScore=");
062                    sb.append(ratingsAverageScore);
063                    sb.append("}");
064    
065                    return sb.toString();
066            }
067    
068            @Override
069            public BlogsStatsUser toEntityModel() {
070                    BlogsStatsUserImpl blogsStatsUserImpl = new BlogsStatsUserImpl();
071    
072                    blogsStatsUserImpl.setStatsUserId(statsUserId);
073                    blogsStatsUserImpl.setGroupId(groupId);
074                    blogsStatsUserImpl.setCompanyId(companyId);
075                    blogsStatsUserImpl.setUserId(userId);
076                    blogsStatsUserImpl.setEntryCount(entryCount);
077    
078                    if (lastPostDate == Long.MIN_VALUE) {
079                            blogsStatsUserImpl.setLastPostDate(null);
080                    }
081                    else {
082                            blogsStatsUserImpl.setLastPostDate(new Date(lastPostDate));
083                    }
084    
085                    blogsStatsUserImpl.setRatingsTotalEntries(ratingsTotalEntries);
086                    blogsStatsUserImpl.setRatingsTotalScore(ratingsTotalScore);
087                    blogsStatsUserImpl.setRatingsAverageScore(ratingsAverageScore);
088    
089                    blogsStatsUserImpl.resetOriginalValues();
090    
091                    return blogsStatsUserImpl;
092            }
093    
094            @Override
095            public void readExternal(ObjectInput objectInput) throws IOException {
096                    statsUserId = objectInput.readLong();
097                    groupId = objectInput.readLong();
098                    companyId = objectInput.readLong();
099                    userId = objectInput.readLong();
100                    entryCount = objectInput.readInt();
101                    lastPostDate = objectInput.readLong();
102                    ratingsTotalEntries = objectInput.readInt();
103                    ratingsTotalScore = objectInput.readDouble();
104                    ratingsAverageScore = objectInput.readDouble();
105            }
106    
107            @Override
108            public void writeExternal(ObjectOutput objectOutput)
109                    throws IOException {
110                    objectOutput.writeLong(statsUserId);
111                    objectOutput.writeLong(groupId);
112                    objectOutput.writeLong(companyId);
113                    objectOutput.writeLong(userId);
114                    objectOutput.writeInt(entryCount);
115                    objectOutput.writeLong(lastPostDate);
116                    objectOutput.writeInt(ratingsTotalEntries);
117                    objectOutput.writeDouble(ratingsTotalScore);
118                    objectOutput.writeDouble(ratingsAverageScore);
119            }
120    
121            public long statsUserId;
122            public long groupId;
123            public long companyId;
124            public long userId;
125            public int entryCount;
126            public long lastPostDate;
127            public int ratingsTotalEntries;
128            public double ratingsTotalScore;
129            public double ratingsAverageScore;
130    }