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