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