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(19);
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("}");
090    
091                    return sb.toString();
092            }
093    
094            @Override
095            public MBThreadFlag toEntityModel() {
096                    MBThreadFlagImpl mbThreadFlagImpl = new MBThreadFlagImpl();
097    
098                    if (uuid == null) {
099                            mbThreadFlagImpl.setUuid(StringPool.BLANK);
100                    }
101                    else {
102                            mbThreadFlagImpl.setUuid(uuid);
103                    }
104    
105                    mbThreadFlagImpl.setThreadFlagId(threadFlagId);
106                    mbThreadFlagImpl.setGroupId(groupId);
107                    mbThreadFlagImpl.setCompanyId(companyId);
108                    mbThreadFlagImpl.setUserId(userId);
109    
110                    if (userName == null) {
111                            mbThreadFlagImpl.setUserName(StringPool.BLANK);
112                    }
113                    else {
114                            mbThreadFlagImpl.setUserName(userName);
115                    }
116    
117                    if (createDate == Long.MIN_VALUE) {
118                            mbThreadFlagImpl.setCreateDate(null);
119                    }
120                    else {
121                            mbThreadFlagImpl.setCreateDate(new Date(createDate));
122                    }
123    
124                    if (modifiedDate == Long.MIN_VALUE) {
125                            mbThreadFlagImpl.setModifiedDate(null);
126                    }
127                    else {
128                            mbThreadFlagImpl.setModifiedDate(new Date(modifiedDate));
129                    }
130    
131                    mbThreadFlagImpl.setThreadId(threadId);
132    
133                    mbThreadFlagImpl.resetOriginalValues();
134    
135                    return mbThreadFlagImpl;
136            }
137    
138            @Override
139            public void readExternal(ObjectInput objectInput) throws IOException {
140                    uuid = objectInput.readUTF();
141                    threadFlagId = objectInput.readLong();
142                    groupId = objectInput.readLong();
143                    companyId = objectInput.readLong();
144                    userId = objectInput.readLong();
145                    userName = objectInput.readUTF();
146                    createDate = objectInput.readLong();
147                    modifiedDate = objectInput.readLong();
148                    threadId = objectInput.readLong();
149            }
150    
151            @Override
152            public void writeExternal(ObjectOutput objectOutput)
153                    throws IOException {
154                    if (uuid == null) {
155                            objectOutput.writeUTF(StringPool.BLANK);
156                    }
157                    else {
158                            objectOutput.writeUTF(uuid);
159                    }
160    
161                    objectOutput.writeLong(threadFlagId);
162                    objectOutput.writeLong(groupId);
163                    objectOutput.writeLong(companyId);
164                    objectOutput.writeLong(userId);
165    
166                    if (userName == null) {
167                            objectOutput.writeUTF(StringPool.BLANK);
168                    }
169                    else {
170                            objectOutput.writeUTF(userName);
171                    }
172    
173                    objectOutput.writeLong(createDate);
174                    objectOutput.writeLong(modifiedDate);
175                    objectOutput.writeLong(threadId);
176            }
177    
178            public String uuid;
179            public long threadFlagId;
180            public long groupId;
181            public long companyId;
182            public long userId;
183            public String userName;
184            public long createDate;
185            public long modifiedDate;
186            public long threadId;
187    }