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