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.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.CacheModel;
022    
023    import com.liferay.portlet.asset.model.AssetTag;
024    
025    import java.io.Externalizable;
026    import java.io.IOException;
027    import java.io.ObjectInput;
028    import java.io.ObjectOutput;
029    
030    import java.util.Date;
031    
032    /**
033     * The cache model class for representing AssetTag in entity cache.
034     *
035     * @author Brian Wing Shun Chan
036     * @see AssetTag
037     * @generated
038     */
039    @ProviderType
040    public class AssetTagCacheModel implements CacheModel<AssetTag>, Externalizable {
041            @Override
042            public String toString() {
043                    StringBundler sb = new StringBundler(19);
044    
045                    sb.append("{tagId=");
046                    sb.append(tagId);
047                    sb.append(", groupId=");
048                    sb.append(groupId);
049                    sb.append(", companyId=");
050                    sb.append(companyId);
051                    sb.append(", userId=");
052                    sb.append(userId);
053                    sb.append(", userName=");
054                    sb.append(userName);
055                    sb.append(", createDate=");
056                    sb.append(createDate);
057                    sb.append(", modifiedDate=");
058                    sb.append(modifiedDate);
059                    sb.append(", name=");
060                    sb.append(name);
061                    sb.append(", assetCount=");
062                    sb.append(assetCount);
063                    sb.append("}");
064    
065                    return sb.toString();
066            }
067    
068            @Override
069            public AssetTag toEntityModel() {
070                    AssetTagImpl assetTagImpl = new AssetTagImpl();
071    
072                    assetTagImpl.setTagId(tagId);
073                    assetTagImpl.setGroupId(groupId);
074                    assetTagImpl.setCompanyId(companyId);
075                    assetTagImpl.setUserId(userId);
076    
077                    if (userName == null) {
078                            assetTagImpl.setUserName(StringPool.BLANK);
079                    }
080                    else {
081                            assetTagImpl.setUserName(userName);
082                    }
083    
084                    if (createDate == Long.MIN_VALUE) {
085                            assetTagImpl.setCreateDate(null);
086                    }
087                    else {
088                            assetTagImpl.setCreateDate(new Date(createDate));
089                    }
090    
091                    if (modifiedDate == Long.MIN_VALUE) {
092                            assetTagImpl.setModifiedDate(null);
093                    }
094                    else {
095                            assetTagImpl.setModifiedDate(new Date(modifiedDate));
096                    }
097    
098                    if (name == null) {
099                            assetTagImpl.setName(StringPool.BLANK);
100                    }
101                    else {
102                            assetTagImpl.setName(name);
103                    }
104    
105                    assetTagImpl.setAssetCount(assetCount);
106    
107                    assetTagImpl.resetOriginalValues();
108    
109                    return assetTagImpl;
110            }
111    
112            @Override
113            public void readExternal(ObjectInput objectInput) throws IOException {
114                    tagId = objectInput.readLong();
115                    groupId = objectInput.readLong();
116                    companyId = objectInput.readLong();
117                    userId = objectInput.readLong();
118                    userName = objectInput.readUTF();
119                    createDate = objectInput.readLong();
120                    modifiedDate = objectInput.readLong();
121                    name = objectInput.readUTF();
122                    assetCount = objectInput.readInt();
123            }
124    
125            @Override
126            public void writeExternal(ObjectOutput objectOutput)
127                    throws IOException {
128                    objectOutput.writeLong(tagId);
129                    objectOutput.writeLong(groupId);
130                    objectOutput.writeLong(companyId);
131                    objectOutput.writeLong(userId);
132    
133                    if (userName == null) {
134                            objectOutput.writeUTF(StringPool.BLANK);
135                    }
136                    else {
137                            objectOutput.writeUTF(userName);
138                    }
139    
140                    objectOutput.writeLong(createDate);
141                    objectOutput.writeLong(modifiedDate);
142    
143                    if (name == null) {
144                            objectOutput.writeUTF(StringPool.BLANK);
145                    }
146                    else {
147                            objectOutput.writeUTF(name);
148                    }
149    
150                    objectOutput.writeInt(assetCount);
151            }
152    
153            public long tagId;
154            public long groupId;
155            public long companyId;
156            public long userId;
157            public String userName;
158            public long createDate;
159            public long modifiedDate;
160            public String name;
161            public int assetCount;
162    }