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