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