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.AssetCategory;
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 AssetCategory in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see AssetCategory
035     * @generated
036     */
037    public class AssetCategoryCacheModel implements CacheModel<AssetCategory>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(31);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", categoryId=");
046                    sb.append(categoryId);
047                    sb.append(", groupId=");
048                    sb.append(groupId);
049                    sb.append(", companyId=");
050                    sb.append(companyId);
051                    sb.append(", userId=");
052                    sb.append(userId);
053                    sb.append(", userName=");
054                    sb.append(userName);
055                    sb.append(", createDate=");
056                    sb.append(createDate);
057                    sb.append(", modifiedDate=");
058                    sb.append(modifiedDate);
059                    sb.append(", parentCategoryId=");
060                    sb.append(parentCategoryId);
061                    sb.append(", leftCategoryId=");
062                    sb.append(leftCategoryId);
063                    sb.append(", rightCategoryId=");
064                    sb.append(rightCategoryId);
065                    sb.append(", name=");
066                    sb.append(name);
067                    sb.append(", title=");
068                    sb.append(title);
069                    sb.append(", description=");
070                    sb.append(description);
071                    sb.append(", vocabularyId=");
072                    sb.append(vocabularyId);
073                    sb.append("}");
074    
075                    return sb.toString();
076            }
077    
078            @Override
079            public AssetCategory toEntityModel() {
080                    AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
081    
082                    if (uuid == null) {
083                            assetCategoryImpl.setUuid(StringPool.BLANK);
084                    }
085                    else {
086                            assetCategoryImpl.setUuid(uuid);
087                    }
088    
089                    assetCategoryImpl.setCategoryId(categoryId);
090                    assetCategoryImpl.setGroupId(groupId);
091                    assetCategoryImpl.setCompanyId(companyId);
092                    assetCategoryImpl.setUserId(userId);
093    
094                    if (userName == null) {
095                            assetCategoryImpl.setUserName(StringPool.BLANK);
096                    }
097                    else {
098                            assetCategoryImpl.setUserName(userName);
099                    }
100    
101                    if (createDate == Long.MIN_VALUE) {
102                            assetCategoryImpl.setCreateDate(null);
103                    }
104                    else {
105                            assetCategoryImpl.setCreateDate(new Date(createDate));
106                    }
107    
108                    if (modifiedDate == Long.MIN_VALUE) {
109                            assetCategoryImpl.setModifiedDate(null);
110                    }
111                    else {
112                            assetCategoryImpl.setModifiedDate(new Date(modifiedDate));
113                    }
114    
115                    assetCategoryImpl.setParentCategoryId(parentCategoryId);
116                    assetCategoryImpl.setLeftCategoryId(leftCategoryId);
117                    assetCategoryImpl.setRightCategoryId(rightCategoryId);
118    
119                    if (name == null) {
120                            assetCategoryImpl.setName(StringPool.BLANK);
121                    }
122                    else {
123                            assetCategoryImpl.setName(name);
124                    }
125    
126                    if (title == null) {
127                            assetCategoryImpl.setTitle(StringPool.BLANK);
128                    }
129                    else {
130                            assetCategoryImpl.setTitle(title);
131                    }
132    
133                    if (description == null) {
134                            assetCategoryImpl.setDescription(StringPool.BLANK);
135                    }
136                    else {
137                            assetCategoryImpl.setDescription(description);
138                    }
139    
140                    assetCategoryImpl.setVocabularyId(vocabularyId);
141    
142                    assetCategoryImpl.resetOriginalValues();
143    
144                    return assetCategoryImpl;
145            }
146    
147            @Override
148            public void readExternal(ObjectInput objectInput) throws IOException {
149                    uuid = objectInput.readUTF();
150                    categoryId = objectInput.readLong();
151                    groupId = objectInput.readLong();
152                    companyId = objectInput.readLong();
153                    userId = objectInput.readLong();
154                    userName = objectInput.readUTF();
155                    createDate = objectInput.readLong();
156                    modifiedDate = objectInput.readLong();
157                    parentCategoryId = objectInput.readLong();
158                    leftCategoryId = objectInput.readLong();
159                    rightCategoryId = objectInput.readLong();
160                    name = objectInput.readUTF();
161                    title = objectInput.readUTF();
162                    description = objectInput.readUTF();
163                    vocabularyId = objectInput.readLong();
164            }
165    
166            @Override
167            public void writeExternal(ObjectOutput objectOutput)
168                    throws IOException {
169                    if (uuid == null) {
170                            objectOutput.writeUTF(StringPool.BLANK);
171                    }
172                    else {
173                            objectOutput.writeUTF(uuid);
174                    }
175    
176                    objectOutput.writeLong(categoryId);
177                    objectOutput.writeLong(groupId);
178                    objectOutput.writeLong(companyId);
179                    objectOutput.writeLong(userId);
180    
181                    if (userName == null) {
182                            objectOutput.writeUTF(StringPool.BLANK);
183                    }
184                    else {
185                            objectOutput.writeUTF(userName);
186                    }
187    
188                    objectOutput.writeLong(createDate);
189                    objectOutput.writeLong(modifiedDate);
190                    objectOutput.writeLong(parentCategoryId);
191                    objectOutput.writeLong(leftCategoryId);
192                    objectOutput.writeLong(rightCategoryId);
193    
194                    if (name == null) {
195                            objectOutput.writeUTF(StringPool.BLANK);
196                    }
197                    else {
198                            objectOutput.writeUTF(name);
199                    }
200    
201                    if (title == null) {
202                            objectOutput.writeUTF(StringPool.BLANK);
203                    }
204                    else {
205                            objectOutput.writeUTF(title);
206                    }
207    
208                    if (description == null) {
209                            objectOutput.writeUTF(StringPool.BLANK);
210                    }
211                    else {
212                            objectOutput.writeUTF(description);
213                    }
214    
215                    objectOutput.writeLong(vocabularyId);
216            }
217    
218            public String uuid;
219            public long categoryId;
220            public long groupId;
221            public long companyId;
222            public long userId;
223            public String userName;
224            public long createDate;
225            public long modifiedDate;
226            public long parentCategoryId;
227            public long leftCategoryId;
228            public long rightCategoryId;
229            public String name;
230            public String title;
231            public String description;
232            public long vocabularyId;
233    }