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