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