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