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.HashUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.CacheModel;
023    
024    import com.liferay.portlet.asset.model.AssetCategoryProperty;
025    
026    import java.io.Externalizable;
027    import java.io.IOException;
028    import java.io.ObjectInput;
029    import java.io.ObjectOutput;
030    
031    import java.util.Date;
032    
033    /**
034     * The cache model class for representing AssetCategoryProperty in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see AssetCategoryProperty
038     * @generated
039     */
040    @ProviderType
041    public class AssetCategoryPropertyCacheModel implements CacheModel<AssetCategoryProperty>,
042            Externalizable {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof AssetCategoryPropertyCacheModel)) {
050                            return false;
051                    }
052    
053                    AssetCategoryPropertyCacheModel assetCategoryPropertyCacheModel = (AssetCategoryPropertyCacheModel)obj;
054    
055                    if (categoryPropertyId == assetCategoryPropertyCacheModel.categoryPropertyId) {
056                            return true;
057                    }
058    
059                    return false;
060            }
061    
062            @Override
063            public int hashCode() {
064                    return HashUtil.hash(0, categoryPropertyId);
065            }
066    
067            @Override
068            public String toString() {
069                    StringBundler sb = new StringBundler(19);
070    
071                    sb.append("{categoryPropertyId=");
072                    sb.append(categoryPropertyId);
073                    sb.append(", companyId=");
074                    sb.append(companyId);
075                    sb.append(", userId=");
076                    sb.append(userId);
077                    sb.append(", userName=");
078                    sb.append(userName);
079                    sb.append(", createDate=");
080                    sb.append(createDate);
081                    sb.append(", modifiedDate=");
082                    sb.append(modifiedDate);
083                    sb.append(", categoryId=");
084                    sb.append(categoryId);
085                    sb.append(", key=");
086                    sb.append(key);
087                    sb.append(", value=");
088                    sb.append(value);
089                    sb.append("}");
090    
091                    return sb.toString();
092            }
093    
094            @Override
095            public AssetCategoryProperty toEntityModel() {
096                    AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
097    
098                    assetCategoryPropertyImpl.setCategoryPropertyId(categoryPropertyId);
099                    assetCategoryPropertyImpl.setCompanyId(companyId);
100                    assetCategoryPropertyImpl.setUserId(userId);
101    
102                    if (userName == null) {
103                            assetCategoryPropertyImpl.setUserName(StringPool.BLANK);
104                    }
105                    else {
106                            assetCategoryPropertyImpl.setUserName(userName);
107                    }
108    
109                    if (createDate == Long.MIN_VALUE) {
110                            assetCategoryPropertyImpl.setCreateDate(null);
111                    }
112                    else {
113                            assetCategoryPropertyImpl.setCreateDate(new Date(createDate));
114                    }
115    
116                    if (modifiedDate == Long.MIN_VALUE) {
117                            assetCategoryPropertyImpl.setModifiedDate(null);
118                    }
119                    else {
120                            assetCategoryPropertyImpl.setModifiedDate(new Date(modifiedDate));
121                    }
122    
123                    assetCategoryPropertyImpl.setCategoryId(categoryId);
124    
125                    if (key == null) {
126                            assetCategoryPropertyImpl.setKey(StringPool.BLANK);
127                    }
128                    else {
129                            assetCategoryPropertyImpl.setKey(key);
130                    }
131    
132                    if (value == null) {
133                            assetCategoryPropertyImpl.setValue(StringPool.BLANK);
134                    }
135                    else {
136                            assetCategoryPropertyImpl.setValue(value);
137                    }
138    
139                    assetCategoryPropertyImpl.resetOriginalValues();
140    
141                    return assetCategoryPropertyImpl;
142            }
143    
144            @Override
145            public void readExternal(ObjectInput objectInput) throws IOException {
146                    categoryPropertyId = objectInput.readLong();
147                    companyId = objectInput.readLong();
148                    userId = objectInput.readLong();
149                    userName = objectInput.readUTF();
150                    createDate = objectInput.readLong();
151                    modifiedDate = objectInput.readLong();
152                    categoryId = objectInput.readLong();
153                    key = objectInput.readUTF();
154                    value = objectInput.readUTF();
155            }
156    
157            @Override
158            public void writeExternal(ObjectOutput objectOutput)
159                    throws IOException {
160                    objectOutput.writeLong(categoryPropertyId);
161                    objectOutput.writeLong(companyId);
162                    objectOutput.writeLong(userId);
163    
164                    if (userName == null) {
165                            objectOutput.writeUTF(StringPool.BLANK);
166                    }
167                    else {
168                            objectOutput.writeUTF(userName);
169                    }
170    
171                    objectOutput.writeLong(createDate);
172                    objectOutput.writeLong(modifiedDate);
173                    objectOutput.writeLong(categoryId);
174    
175                    if (key == null) {
176                            objectOutput.writeUTF(StringPool.BLANK);
177                    }
178                    else {
179                            objectOutput.writeUTF(key);
180                    }
181    
182                    if (value == null) {
183                            objectOutput.writeUTF(StringPool.BLANK);
184                    }
185                    else {
186                            objectOutput.writeUTF(value);
187                    }
188            }
189    
190            public long categoryPropertyId;
191            public long companyId;
192            public long userId;
193            public String userName;
194            public long createDate;
195            public long modifiedDate;
196            public long categoryId;
197            public String key;
198            public String value;
199    }