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            public AssetTag toEntityModel() {
066                    AssetTagImpl assetTagImpl = new AssetTagImpl();
067    
068                    assetTagImpl.setTagId(tagId);
069                    assetTagImpl.setGroupId(groupId);
070                    assetTagImpl.setCompanyId(companyId);
071                    assetTagImpl.setUserId(userId);
072    
073                    if (userName == null) {
074                            assetTagImpl.setUserName(StringPool.BLANK);
075                    }
076                    else {
077                            assetTagImpl.setUserName(userName);
078                    }
079    
080                    if (createDate == Long.MIN_VALUE) {
081                            assetTagImpl.setCreateDate(null);
082                    }
083                    else {
084                            assetTagImpl.setCreateDate(new Date(createDate));
085                    }
086    
087                    if (modifiedDate == Long.MIN_VALUE) {
088                            assetTagImpl.setModifiedDate(null);
089                    }
090                    else {
091                            assetTagImpl.setModifiedDate(new Date(modifiedDate));
092                    }
093    
094                    if (name == null) {
095                            assetTagImpl.setName(StringPool.BLANK);
096                    }
097                    else {
098                            assetTagImpl.setName(name);
099                    }
100    
101                    assetTagImpl.setAssetCount(assetCount);
102    
103                    assetTagImpl.resetOriginalValues();
104    
105                    return assetTagImpl;
106            }
107    
108            public void readExternal(ObjectInput objectInput) throws IOException {
109                    tagId = objectInput.readLong();
110                    groupId = objectInput.readLong();
111                    companyId = objectInput.readLong();
112                    userId = objectInput.readLong();
113                    userName = objectInput.readUTF();
114                    createDate = objectInput.readLong();
115                    modifiedDate = objectInput.readLong();
116                    name = objectInput.readUTF();
117                    assetCount = objectInput.readInt();
118            }
119    
120            public void writeExternal(ObjectOutput objectOutput)
121                    throws IOException {
122                    objectOutput.writeLong(tagId);
123                    objectOutput.writeLong(groupId);
124                    objectOutput.writeLong(companyId);
125                    objectOutput.writeLong(userId);
126    
127                    if (userName == null) {
128                            objectOutput.writeUTF(StringPool.BLANK);
129                    }
130                    else {
131                            objectOutput.writeUTF(userName);
132                    }
133    
134                    objectOutput.writeLong(createDate);
135                    objectOutput.writeLong(modifiedDate);
136    
137                    if (name == null) {
138                            objectOutput.writeUTF(StringPool.BLANK);
139                    }
140                    else {
141                            objectOutput.writeUTF(name);
142                    }
143    
144                    objectOutput.writeInt(assetCount);
145            }
146    
147            public long tagId;
148            public long groupId;
149            public long companyId;
150            public long userId;
151            public String userName;
152            public long createDate;
153            public long modifiedDate;
154            public String name;
155            public int assetCount;
156    }