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