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.MBThreadFlag;
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                    threadFlagId = objectInput.readLong();
151                    groupId = objectInput.readLong();
152                    companyId = objectInput.readLong();
153                    userId = objectInput.readLong();
154                    userName = objectInput.readUTF();
155                    createDate = objectInput.readLong();
156                    modifiedDate = objectInput.readLong();
157                    threadId = objectInput.readLong();
158                    lastPublishDate = objectInput.readLong();
159            }
160    
161            @Override
162            public void writeExternal(ObjectOutput objectOutput)
163                    throws IOException {
164                    if (uuid == null) {
165                            objectOutput.writeUTF(StringPool.BLANK);
166                    }
167                    else {
168                            objectOutput.writeUTF(uuid);
169                    }
170    
171                    objectOutput.writeLong(threadFlagId);
172                    objectOutput.writeLong(groupId);
173                    objectOutput.writeLong(companyId);
174                    objectOutput.writeLong(userId);
175    
176                    if (userName == null) {
177                            objectOutput.writeUTF(StringPool.BLANK);
178                    }
179                    else {
180                            objectOutput.writeUTF(userName);
181                    }
182    
183                    objectOutput.writeLong(createDate);
184                    objectOutput.writeLong(modifiedDate);
185                    objectOutput.writeLong(threadId);
186                    objectOutput.writeLong(lastPublishDate);
187            }
188    
189            public String uuid;
190            public long threadFlagId;
191            public long groupId;
192            public long companyId;
193            public long userId;
194            public String userName;
195            public long createDate;
196            public long modifiedDate;
197            public long threadId;
198            public long lastPublishDate;
199    }