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            public MBThreadFlag toEntityModel() {
067                    MBThreadFlagImpl mbThreadFlagImpl = new MBThreadFlagImpl();
068    
069                    if (uuid == null) {
070                            mbThreadFlagImpl.setUuid(StringPool.BLANK);
071                    }
072                    else {
073                            mbThreadFlagImpl.setUuid(uuid);
074                    }
075    
076                    mbThreadFlagImpl.setThreadFlagId(threadFlagId);
077                    mbThreadFlagImpl.setGroupId(groupId);
078                    mbThreadFlagImpl.setCompanyId(companyId);
079                    mbThreadFlagImpl.setUserId(userId);
080    
081                    if (userName == null) {
082                            mbThreadFlagImpl.setUserName(StringPool.BLANK);
083                    }
084                    else {
085                            mbThreadFlagImpl.setUserName(userName);
086                    }
087    
088                    if (createDate == Long.MIN_VALUE) {
089                            mbThreadFlagImpl.setCreateDate(null);
090                    }
091                    else {
092                            mbThreadFlagImpl.setCreateDate(new Date(createDate));
093                    }
094    
095                    if (modifiedDate == Long.MIN_VALUE) {
096                            mbThreadFlagImpl.setModifiedDate(null);
097                    }
098                    else {
099                            mbThreadFlagImpl.setModifiedDate(new Date(modifiedDate));
100                    }
101    
102                    mbThreadFlagImpl.setThreadId(threadId);
103    
104                    mbThreadFlagImpl.resetOriginalValues();
105    
106                    return mbThreadFlagImpl;
107            }
108    
109            public void readExternal(ObjectInput objectInput) throws IOException {
110                    uuid = objectInput.readUTF();
111                    threadFlagId = objectInput.readLong();
112                    groupId = objectInput.readLong();
113                    companyId = objectInput.readLong();
114                    userId = objectInput.readLong();
115                    userName = objectInput.readUTF();
116                    createDate = objectInput.readLong();
117                    modifiedDate = objectInput.readLong();
118                    threadId = objectInput.readLong();
119            }
120    
121            public void writeExternal(ObjectOutput objectOutput)
122                    throws IOException {
123                    if (uuid == null) {
124                            objectOutput.writeUTF(StringPool.BLANK);
125                    }
126                    else {
127                            objectOutput.writeUTF(uuid);
128                    }
129    
130                    objectOutput.writeLong(threadFlagId);
131                    objectOutput.writeLong(groupId);
132                    objectOutput.writeLong(companyId);
133                    objectOutput.writeLong(userId);
134    
135                    if (userName == null) {
136                            objectOutput.writeUTF(StringPool.BLANK);
137                    }
138                    else {
139                            objectOutput.writeUTF(userName);
140                    }
141    
142                    objectOutput.writeLong(createDate);
143                    objectOutput.writeLong(modifiedDate);
144                    objectOutput.writeLong(threadId);
145            }
146    
147            public String uuid;
148            public long threadFlagId;
149            public long groupId;
150            public long companyId;
151            public long userId;
152            public String userName;
153            public long createDate;
154            public long modifiedDate;
155            public long threadId;
156    }