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.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    
021    import com.liferay.portlet.messageboards.model.MBBan;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    import java.util.Date;
029    
030    /**
031     * The cache model class for representing MBBan in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see MBBan
035     * @generated
036     */
037    public class MBBanCacheModel implements CacheModel<MBBan>, Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(17);
041    
042                    sb.append("{banId=");
043                    sb.append(banId);
044                    sb.append(", groupId=");
045                    sb.append(groupId);
046                    sb.append(", companyId=");
047                    sb.append(companyId);
048                    sb.append(", userId=");
049                    sb.append(userId);
050                    sb.append(", userName=");
051                    sb.append(userName);
052                    sb.append(", createDate=");
053                    sb.append(createDate);
054                    sb.append(", modifiedDate=");
055                    sb.append(modifiedDate);
056                    sb.append(", banUserId=");
057                    sb.append(banUserId);
058                    sb.append("}");
059    
060                    return sb.toString();
061            }
062    
063            public MBBan toEntityModel() {
064                    MBBanImpl mbBanImpl = new MBBanImpl();
065    
066                    mbBanImpl.setBanId(banId);
067                    mbBanImpl.setGroupId(groupId);
068                    mbBanImpl.setCompanyId(companyId);
069                    mbBanImpl.setUserId(userId);
070    
071                    if (userName == null) {
072                            mbBanImpl.setUserName(StringPool.BLANK);
073                    }
074                    else {
075                            mbBanImpl.setUserName(userName);
076                    }
077    
078                    if (createDate == Long.MIN_VALUE) {
079                            mbBanImpl.setCreateDate(null);
080                    }
081                    else {
082                            mbBanImpl.setCreateDate(new Date(createDate));
083                    }
084    
085                    if (modifiedDate == Long.MIN_VALUE) {
086                            mbBanImpl.setModifiedDate(null);
087                    }
088                    else {
089                            mbBanImpl.setModifiedDate(new Date(modifiedDate));
090                    }
091    
092                    mbBanImpl.setBanUserId(banUserId);
093    
094                    mbBanImpl.resetOriginalValues();
095    
096                    return mbBanImpl;
097            }
098    
099            public void readExternal(ObjectInput objectInput) throws IOException {
100                    banId = objectInput.readLong();
101                    groupId = objectInput.readLong();
102                    companyId = objectInput.readLong();
103                    userId = objectInput.readLong();
104                    userName = objectInput.readUTF();
105                    createDate = objectInput.readLong();
106                    modifiedDate = objectInput.readLong();
107                    banUserId = objectInput.readLong();
108            }
109    
110            public void writeExternal(ObjectOutput objectOutput)
111                    throws IOException {
112                    objectOutput.writeLong(banId);
113                    objectOutput.writeLong(groupId);
114                    objectOutput.writeLong(companyId);
115                    objectOutput.writeLong(userId);
116    
117                    if (userName == null) {
118                            objectOutput.writeUTF(StringPool.BLANK);
119                    }
120                    else {
121                            objectOutput.writeUTF(userName);
122                    }
123    
124                    objectOutput.writeLong(createDate);
125                    objectOutput.writeLong(modifiedDate);
126                    objectOutput.writeLong(banUserId);
127            }
128    
129            public long banId;
130            public long groupId;
131            public long companyId;
132            public long userId;
133            public String userName;
134            public long createDate;
135            public long modifiedDate;
136            public long banUserId;
137    }