001    /**
002     * Copyright (c) 2000-2013 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            @Override
058            public MBStatsUser toEntityModel() {
059                    MBStatsUserImpl mbStatsUserImpl = new MBStatsUserImpl();
060    
061                    mbStatsUserImpl.setStatsUserId(statsUserId);
062                    mbStatsUserImpl.setGroupId(groupId);
063                    mbStatsUserImpl.setUserId(userId);
064                    mbStatsUserImpl.setMessageCount(messageCount);
065    
066                    if (lastPostDate == Long.MIN_VALUE) {
067                            mbStatsUserImpl.setLastPostDate(null);
068                    }
069                    else {
070                            mbStatsUserImpl.setLastPostDate(new Date(lastPostDate));
071                    }
072    
073                    mbStatsUserImpl.resetOriginalValues();
074    
075                    return mbStatsUserImpl;
076            }
077    
078            @Override
079            public void readExternal(ObjectInput objectInput) throws IOException {
080                    statsUserId = objectInput.readLong();
081                    groupId = objectInput.readLong();
082                    userId = objectInput.readLong();
083                    messageCount = objectInput.readInt();
084                    lastPostDate = objectInput.readLong();
085            }
086    
087            @Override
088            public void writeExternal(ObjectOutput objectOutput)
089                    throws IOException {
090                    objectOutput.writeLong(statsUserId);
091                    objectOutput.writeLong(groupId);
092                    objectOutput.writeLong(userId);
093                    objectOutput.writeInt(messageCount);
094                    objectOutput.writeLong(lastPostDate);
095            }
096    
097            public long statsUserId;
098            public long groupId;
099            public long userId;
100            public int messageCount;
101            public long lastPostDate;
102    }