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.messageboards.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.messageboards.model.MBStatsUser;
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 MBStatsUser in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see MBStatsUser
036     * @generated
037     */
038    @ProviderType
039    public class MBStatsUserCacheModel implements CacheModel<MBStatsUser>,
040            Externalizable {
041            @Override
042            public String toString() {
043                    StringBundler sb = new StringBundler(11);
044    
045                    sb.append("{statsUserId=");
046                    sb.append(statsUserId);
047                    sb.append(", groupId=");
048                    sb.append(groupId);
049                    sb.append(", userId=");
050                    sb.append(userId);
051                    sb.append(", messageCount=");
052                    sb.append(messageCount);
053                    sb.append(", lastPostDate=");
054                    sb.append(lastPostDate);
055                    sb.append("}");
056    
057                    return sb.toString();
058            }
059    
060            @Override
061            public MBStatsUser toEntityModel() {
062                    MBStatsUserImpl mbStatsUserImpl = new MBStatsUserImpl();
063    
064                    mbStatsUserImpl.setStatsUserId(statsUserId);
065                    mbStatsUserImpl.setGroupId(groupId);
066                    mbStatsUserImpl.setUserId(userId);
067                    mbStatsUserImpl.setMessageCount(messageCount);
068    
069                    if (lastPostDate == Long.MIN_VALUE) {
070                            mbStatsUserImpl.setLastPostDate(null);
071                    }
072                    else {
073                            mbStatsUserImpl.setLastPostDate(new Date(lastPostDate));
074                    }
075    
076                    mbStatsUserImpl.resetOriginalValues();
077    
078                    return mbStatsUserImpl;
079            }
080    
081            @Override
082            public void readExternal(ObjectInput objectInput) throws IOException {
083                    statsUserId = objectInput.readLong();
084                    groupId = objectInput.readLong();
085                    userId = objectInput.readLong();
086                    messageCount = objectInput.readInt();
087                    lastPostDate = objectInput.readLong();
088            }
089    
090            @Override
091            public void writeExternal(ObjectOutput objectOutput)
092                    throws IOException {
093                    objectOutput.writeLong(statsUserId);
094                    objectOutput.writeLong(groupId);
095                    objectOutput.writeLong(userId);
096                    objectOutput.writeInt(messageCount);
097                    objectOutput.writeLong(lastPostDate);
098            }
099    
100            public long statsUserId;
101            public long groupId;
102            public long userId;
103            public int messageCount;
104            public long lastPostDate;
105    }