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