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.MBDiscussion;
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 MBDiscussion in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see MBDiscussion
035     * @generated
036     */
037    public class MBDiscussionCacheModel implements CacheModel<MBDiscussion>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(23);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", discussionId=");
046                    sb.append(discussionId);
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(", classNameId=");
060                    sb.append(classNameId);
061                    sb.append(", classPK=");
062                    sb.append(classPK);
063                    sb.append(", threadId=");
064                    sb.append(threadId);
065                    sb.append("}");
066    
067                    return sb.toString();
068            }
069    
070            @Override
071            public MBDiscussion toEntityModel() {
072                    MBDiscussionImpl mbDiscussionImpl = new MBDiscussionImpl();
073    
074                    if (uuid == null) {
075                            mbDiscussionImpl.setUuid(StringPool.BLANK);
076                    }
077                    else {
078                            mbDiscussionImpl.setUuid(uuid);
079                    }
080    
081                    mbDiscussionImpl.setDiscussionId(discussionId);
082                    mbDiscussionImpl.setGroupId(groupId);
083                    mbDiscussionImpl.setCompanyId(companyId);
084                    mbDiscussionImpl.setUserId(userId);
085    
086                    if (userName == null) {
087                            mbDiscussionImpl.setUserName(StringPool.BLANK);
088                    }
089                    else {
090                            mbDiscussionImpl.setUserName(userName);
091                    }
092    
093                    if (createDate == Long.MIN_VALUE) {
094                            mbDiscussionImpl.setCreateDate(null);
095                    }
096                    else {
097                            mbDiscussionImpl.setCreateDate(new Date(createDate));
098                    }
099    
100                    if (modifiedDate == Long.MIN_VALUE) {
101                            mbDiscussionImpl.setModifiedDate(null);
102                    }
103                    else {
104                            mbDiscussionImpl.setModifiedDate(new Date(modifiedDate));
105                    }
106    
107                    mbDiscussionImpl.setClassNameId(classNameId);
108                    mbDiscussionImpl.setClassPK(classPK);
109                    mbDiscussionImpl.setThreadId(threadId);
110    
111                    mbDiscussionImpl.resetOriginalValues();
112    
113                    return mbDiscussionImpl;
114            }
115    
116            @Override
117            public void readExternal(ObjectInput objectInput) throws IOException {
118                    uuid = objectInput.readUTF();
119                    discussionId = objectInput.readLong();
120                    groupId = objectInput.readLong();
121                    companyId = objectInput.readLong();
122                    userId = objectInput.readLong();
123                    userName = objectInput.readUTF();
124                    createDate = objectInput.readLong();
125                    modifiedDate = objectInput.readLong();
126                    classNameId = objectInput.readLong();
127                    classPK = objectInput.readLong();
128                    threadId = objectInput.readLong();
129            }
130    
131            @Override
132            public void writeExternal(ObjectOutput objectOutput)
133                    throws IOException {
134                    if (uuid == null) {
135                            objectOutput.writeUTF(StringPool.BLANK);
136                    }
137                    else {
138                            objectOutput.writeUTF(uuid);
139                    }
140    
141                    objectOutput.writeLong(discussionId);
142                    objectOutput.writeLong(groupId);
143                    objectOutput.writeLong(companyId);
144                    objectOutput.writeLong(userId);
145    
146                    if (userName == null) {
147                            objectOutput.writeUTF(StringPool.BLANK);
148                    }
149                    else {
150                            objectOutput.writeUTF(userName);
151                    }
152    
153                    objectOutput.writeLong(createDate);
154                    objectOutput.writeLong(modifiedDate);
155                    objectOutput.writeLong(classNameId);
156                    objectOutput.writeLong(classPK);
157                    objectOutput.writeLong(threadId);
158            }
159    
160            public String uuid;
161            public long discussionId;
162            public long groupId;
163            public long companyId;
164            public long userId;
165            public String userName;
166            public long createDate;
167            public long modifiedDate;
168            public long classNameId;
169            public long classPK;
170            public long threadId;
171    }