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(19);
069    
070                    sb.append("{tagId=");
071                    sb.append(tagId);
072                    sb.append(", groupId=");
073                    sb.append(groupId);
074                    sb.append(", companyId=");
075                    sb.append(companyId);
076                    sb.append(", userId=");
077                    sb.append(userId);
078                    sb.append(", userName=");
079                    sb.append(userName);
080                    sb.append(", createDate=");
081                    sb.append(createDate);
082                    sb.append(", modifiedDate=");
083                    sb.append(modifiedDate);
084                    sb.append(", name=");
085                    sb.append(name);
086                    sb.append(", assetCount=");
087                    sb.append(assetCount);
088                    sb.append("}");
089    
090                    return sb.toString();
091            }
092    
093            @Override
094            public AssetTag toEntityModel() {
095                    AssetTagImpl assetTagImpl = new AssetTagImpl();
096    
097                    assetTagImpl.setTagId(tagId);
098                    assetTagImpl.setGroupId(groupId);
099                    assetTagImpl.setCompanyId(companyId);
100                    assetTagImpl.setUserId(userId);
101    
102                    if (userName == null) {
103                            assetTagImpl.setUserName(StringPool.BLANK);
104                    }
105                    else {
106                            assetTagImpl.setUserName(userName);
107                    }
108    
109                    if (createDate == Long.MIN_VALUE) {
110                            assetTagImpl.setCreateDate(null);
111                    }
112                    else {
113                            assetTagImpl.setCreateDate(new Date(createDate));
114                    }
115    
116                    if (modifiedDate == Long.MIN_VALUE) {
117                            assetTagImpl.setModifiedDate(null);
118                    }
119                    else {
120                            assetTagImpl.setModifiedDate(new Date(modifiedDate));
121                    }
122    
123                    if (name == null) {
124                            assetTagImpl.setName(StringPool.BLANK);
125                    }
126                    else {
127                            assetTagImpl.setName(name);
128                    }
129    
130                    assetTagImpl.setAssetCount(assetCount);
131    
132                    assetTagImpl.resetOriginalValues();
133    
134                    return assetTagImpl;
135            }
136    
137            @Override
138            public void readExternal(ObjectInput objectInput) throws IOException {
139                    tagId = objectInput.readLong();
140                    groupId = objectInput.readLong();
141                    companyId = objectInput.readLong();
142                    userId = objectInput.readLong();
143                    userName = objectInput.readUTF();
144                    createDate = objectInput.readLong();
145                    modifiedDate = objectInput.readLong();
146                    name = objectInput.readUTF();
147                    assetCount = objectInput.readInt();
148            }
149    
150            @Override
151            public void writeExternal(ObjectOutput objectOutput)
152                    throws IOException {
153                    objectOutput.writeLong(tagId);
154                    objectOutput.writeLong(groupId);
155                    objectOutput.writeLong(companyId);
156                    objectOutput.writeLong(userId);
157    
158                    if (userName == null) {
159                            objectOutput.writeUTF(StringPool.BLANK);
160                    }
161                    else {
162                            objectOutput.writeUTF(userName);
163                    }
164    
165                    objectOutput.writeLong(createDate);
166                    objectOutput.writeLong(modifiedDate);
167    
168                    if (name == null) {
169                            objectOutput.writeUTF(StringPool.BLANK);
170                    }
171                    else {
172                            objectOutput.writeUTF(name);
173                    }
174    
175                    objectOutput.writeInt(assetCount);
176            }
177    
178            public long tagId;
179            public long groupId;
180            public long companyId;
181            public long userId;
182            public String userName;
183            public long createDate;
184            public long modifiedDate;
185            public String name;
186            public int assetCount;
187    }