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.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    
021    import com.liferay.portlet.messageboards.model.MBThreadFlag;
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 MBThreadFlag in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see MBThreadFlag
035     * @generated
036     */
037    public class MBThreadFlagCacheModel implements CacheModel<MBThreadFlag>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(19);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", threadFlagId=");
046                    sb.append(threadFlagId);
047                    sb.append(", groupId=");
048                    sb.append(groupId);
049                    sb.append(", companyId=");
050                    sb.append(companyId);
051                    sb.append(", userId=");
052                    sb.append(userId);
053                    sb.append(", userName=");
054                    sb.append(userName);
055                    sb.append(", createDate=");
056                    sb.append(createDate);
057                    sb.append(", modifiedDate=");
058                    sb.append(modifiedDate);
059                    sb.append(", threadId=");
060                    sb.append(threadId);
061                    sb.append("}");
062    
063                    return sb.toString();
064            }
065    
066            @Override
067            public MBThreadFlag toEntityModel() {
068                    MBThreadFlagImpl mbThreadFlagImpl = new MBThreadFlagImpl();
069    
070                    if (uuid == null) {
071                            mbThreadFlagImpl.setUuid(StringPool.BLANK);
072                    }
073                    else {
074                            mbThreadFlagImpl.setUuid(uuid);
075                    }
076    
077                    mbThreadFlagImpl.setThreadFlagId(threadFlagId);
078                    mbThreadFlagImpl.setGroupId(groupId);
079                    mbThreadFlagImpl.setCompanyId(companyId);
080                    mbThreadFlagImpl.setUserId(userId);
081    
082                    if (userName == null) {
083                            mbThreadFlagImpl.setUserName(StringPool.BLANK);
084                    }
085                    else {
086                            mbThreadFlagImpl.setUserName(userName);
087                    }
088    
089                    if (createDate == Long.MIN_VALUE) {
090                            mbThreadFlagImpl.setCreateDate(null);
091                    }
092                    else {
093                            mbThreadFlagImpl.setCreateDate(new Date(createDate));
094                    }
095    
096                    if (modifiedDate == Long.MIN_VALUE) {
097                            mbThreadFlagImpl.setModifiedDate(null);
098                    }
099                    else {
100                            mbThreadFlagImpl.setModifiedDate(new Date(modifiedDate));
101                    }
102    
103                    mbThreadFlagImpl.setThreadId(threadId);
104    
105                    mbThreadFlagImpl.resetOriginalValues();
106    
107                    return mbThreadFlagImpl;
108            }
109    
110            @Override
111            public void readExternal(ObjectInput objectInput) throws IOException {
112                    uuid = objectInput.readUTF();
113                    threadFlagId = objectInput.readLong();
114                    groupId = objectInput.readLong();
115                    companyId = objectInput.readLong();
116                    userId = objectInput.readLong();
117                    userName = objectInput.readUTF();
118                    createDate = objectInput.readLong();
119                    modifiedDate = objectInput.readLong();
120                    threadId = objectInput.readLong();
121            }
122    
123            @Override
124            public void writeExternal(ObjectOutput objectOutput)
125                    throws IOException {
126                    if (uuid == null) {
127                            objectOutput.writeUTF(StringPool.BLANK);
128                    }
129                    else {
130                            objectOutput.writeUTF(uuid);
131                    }
132    
133                    objectOutput.writeLong(threadFlagId);
134                    objectOutput.writeLong(groupId);
135                    objectOutput.writeLong(companyId);
136                    objectOutput.writeLong(userId);
137    
138                    if (userName == null) {
139                            objectOutput.writeUTF(StringPool.BLANK);
140                    }
141                    else {
142                            objectOutput.writeUTF(userName);
143                    }
144    
145                    objectOutput.writeLong(createDate);
146                    objectOutput.writeLong(modifiedDate);
147                    objectOutput.writeLong(threadId);
148            }
149    
150            public String uuid;
151            public long threadFlagId;
152            public long groupId;
153            public long companyId;
154            public long userId;
155            public String userName;
156            public long createDate;
157            public long modifiedDate;
158            public long threadId;
159    }