001    /**
002     * Copyright (c) 2000-2012 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 com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.model.CacheModel;
019    
020    import com.liferay.portlet.messageboards.model.MBStatsUser;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    import java.util.Date;
028    
029    /**
030     * The cache model class for representing MBStatsUser in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see MBStatsUser
034     * @generated
035     */
036    public class MBStatsUserCacheModel implements CacheModel<MBStatsUser>,
037            Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(11);
041    
042                    sb.append("{statsUserId=");
043                    sb.append(statsUserId);
044                    sb.append(", groupId=");
045                    sb.append(groupId);
046                    sb.append(", userId=");
047                    sb.append(userId);
048                    sb.append(", messageCount=");
049                    sb.append(messageCount);
050                    sb.append(", lastPostDate=");
051                    sb.append(lastPostDate);
052                    sb.append("}");
053    
054                    return sb.toString();
055            }
056    
057            public MBStatsUser toEntityModel() {
058                    MBStatsUserImpl mbStatsUserImpl = new MBStatsUserImpl();
059    
060                    mbStatsUserImpl.setStatsUserId(statsUserId);
061                    mbStatsUserImpl.setGroupId(groupId);
062                    mbStatsUserImpl.setUserId(userId);
063                    mbStatsUserImpl.setMessageCount(messageCount);
064    
065                    if (lastPostDate == Long.MIN_VALUE) {
066                            mbStatsUserImpl.setLastPostDate(null);
067                    }
068                    else {
069                            mbStatsUserImpl.setLastPostDate(new Date(lastPostDate));
070                    }
071    
072                    mbStatsUserImpl.resetOriginalValues();
073    
074                    return mbStatsUserImpl;
075            }
076    
077            public void readExternal(ObjectInput objectInput) throws IOException {
078                    statsUserId = objectInput.readLong();
079                    groupId = objectInput.readLong();
080                    userId = objectInput.readLong();
081                    messageCount = objectInput.readInt();
082                    lastPostDate = objectInput.readLong();
083            }
084    
085            public void writeExternal(ObjectOutput objectOutput)
086                    throws IOException {
087                    objectOutput.writeLong(statsUserId);
088                    objectOutput.writeLong(groupId);
089                    objectOutput.writeLong(userId);
090                    objectOutput.writeInt(messageCount);
091                    objectOutput.writeLong(lastPostDate);
092            }
093    
094            public long statsUserId;
095            public long groupId;
096            public long userId;
097            public int messageCount;
098            public long lastPostDate;
099    }