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.AssetTagProperty;
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 AssetTagProperty in entity cache.
034     *
035     * @author Brian Wing Shun Chan
036     * @see AssetTagProperty
037     * @generated
038     */
039    @ProviderType
040    public class AssetTagPropertyCacheModel implements CacheModel<AssetTagProperty>,
041            Externalizable {
042            @Override
043            public String toString() {
044                    StringBundler sb = new StringBundler(19);
045    
046                    sb.append("{tagPropertyId=");
047                    sb.append(tagPropertyId);
048                    sb.append(", companyId=");
049                    sb.append(companyId);
050                    sb.append(", userId=");
051                    sb.append(userId);
052                    sb.append(", userName=");
053                    sb.append(userName);
054                    sb.append(", createDate=");
055                    sb.append(createDate);
056                    sb.append(", modifiedDate=");
057                    sb.append(modifiedDate);
058                    sb.append(", tagId=");
059                    sb.append(tagId);
060                    sb.append(", key=");
061                    sb.append(key);
062                    sb.append(", value=");
063                    sb.append(value);
064                    sb.append("}");
065    
066                    return sb.toString();
067            }
068    
069            @Override
070            public AssetTagProperty toEntityModel() {
071                    AssetTagPropertyImpl assetTagPropertyImpl = new AssetTagPropertyImpl();
072    
073                    assetTagPropertyImpl.setTagPropertyId(tagPropertyId);
074                    assetTagPropertyImpl.setCompanyId(companyId);
075                    assetTagPropertyImpl.setUserId(userId);
076    
077                    if (userName == null) {
078                            assetTagPropertyImpl.setUserName(StringPool.BLANK);
079                    }
080                    else {
081                            assetTagPropertyImpl.setUserName(userName);
082                    }
083    
084                    if (createDate == Long.MIN_VALUE) {
085                            assetTagPropertyImpl.setCreateDate(null);
086                    }
087                    else {
088                            assetTagPropertyImpl.setCreateDate(new Date(createDate));
089                    }
090    
091                    if (modifiedDate == Long.MIN_VALUE) {
092                            assetTagPropertyImpl.setModifiedDate(null);
093                    }
094                    else {
095                            assetTagPropertyImpl.setModifiedDate(new Date(modifiedDate));
096                    }
097    
098                    assetTagPropertyImpl.setTagId(tagId);
099    
100                    if (key == null) {
101                            assetTagPropertyImpl.setKey(StringPool.BLANK);
102                    }
103                    else {
104                            assetTagPropertyImpl.setKey(key);
105                    }
106    
107                    if (value == null) {
108                            assetTagPropertyImpl.setValue(StringPool.BLANK);
109                    }
110                    else {
111                            assetTagPropertyImpl.setValue(value);
112                    }
113    
114                    assetTagPropertyImpl.resetOriginalValues();
115    
116                    return assetTagPropertyImpl;
117            }
118    
119            @Override
120            public void readExternal(ObjectInput objectInput) throws IOException {
121                    tagPropertyId = objectInput.readLong();
122                    companyId = objectInput.readLong();
123                    userId = objectInput.readLong();
124                    userName = objectInput.readUTF();
125                    createDate = objectInput.readLong();
126                    modifiedDate = objectInput.readLong();
127                    tagId = objectInput.readLong();
128                    key = objectInput.readUTF();
129                    value = objectInput.readUTF();
130            }
131    
132            @Override
133            public void writeExternal(ObjectOutput objectOutput)
134                    throws IOException {
135                    objectOutput.writeLong(tagPropertyId);
136                    objectOutput.writeLong(companyId);
137                    objectOutput.writeLong(userId);
138    
139                    if (userName == null) {
140                            objectOutput.writeUTF(StringPool.BLANK);
141                    }
142                    else {
143                            objectOutput.writeUTF(userName);
144                    }
145    
146                    objectOutput.writeLong(createDate);
147                    objectOutput.writeLong(modifiedDate);
148                    objectOutput.writeLong(tagId);
149    
150                    if (key == null) {
151                            objectOutput.writeUTF(StringPool.BLANK);
152                    }
153                    else {
154                            objectOutput.writeUTF(key);
155                    }
156    
157                    if (value == null) {
158                            objectOutput.writeUTF(StringPool.BLANK);
159                    }
160                    else {
161                            objectOutput.writeUTF(value);
162                    }
163            }
164    
165            public long tagPropertyId;
166            public long companyId;
167            public long userId;
168            public String userName;
169            public long createDate;
170            public long modifiedDate;
171            public long tagId;
172            public String key;
173            public String value;
174    }