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.ShoppingCart;
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 ShoppingCart in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see ShoppingCart
035     * @generated
036     */
037    public class ShoppingCartCacheModel implements CacheModel<ShoppingCart>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(23);
042    
043                    sb.append("{cartId=");
044                    sb.append(cartId);
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(", itemIds=");
058                    sb.append(itemIds);
059                    sb.append(", couponCodes=");
060                    sb.append(couponCodes);
061                    sb.append(", altShipping=");
062                    sb.append(altShipping);
063                    sb.append(", insure=");
064                    sb.append(insure);
065                    sb.append("}");
066    
067                    return sb.toString();
068            }
069    
070            @Override
071            public ShoppingCart toEntityModel() {
072                    ShoppingCartImpl shoppingCartImpl = new ShoppingCartImpl();
073    
074                    shoppingCartImpl.setCartId(cartId);
075                    shoppingCartImpl.setGroupId(groupId);
076                    shoppingCartImpl.setCompanyId(companyId);
077                    shoppingCartImpl.setUserId(userId);
078    
079                    if (userName == null) {
080                            shoppingCartImpl.setUserName(StringPool.BLANK);
081                    }
082                    else {
083                            shoppingCartImpl.setUserName(userName);
084                    }
085    
086                    if (createDate == Long.MIN_VALUE) {
087                            shoppingCartImpl.setCreateDate(null);
088                    }
089                    else {
090                            shoppingCartImpl.setCreateDate(new Date(createDate));
091                    }
092    
093                    if (modifiedDate == Long.MIN_VALUE) {
094                            shoppingCartImpl.setModifiedDate(null);
095                    }
096                    else {
097                            shoppingCartImpl.setModifiedDate(new Date(modifiedDate));
098                    }
099    
100                    if (itemIds == null) {
101                            shoppingCartImpl.setItemIds(StringPool.BLANK);
102                    }
103                    else {
104                            shoppingCartImpl.setItemIds(itemIds);
105                    }
106    
107                    if (couponCodes == null) {
108                            shoppingCartImpl.setCouponCodes(StringPool.BLANK);
109                    }
110                    else {
111                            shoppingCartImpl.setCouponCodes(couponCodes);
112                    }
113    
114                    shoppingCartImpl.setAltShipping(altShipping);
115                    shoppingCartImpl.setInsure(insure);
116    
117                    shoppingCartImpl.resetOriginalValues();
118    
119                    return shoppingCartImpl;
120            }
121    
122            @Override
123            public void readExternal(ObjectInput objectInput) throws IOException {
124                    cartId = 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                    itemIds = objectInput.readUTF();
132                    couponCodes = objectInput.readUTF();
133                    altShipping = objectInput.readInt();
134                    insure = objectInput.readBoolean();
135            }
136    
137            @Override
138            public void writeExternal(ObjectOutput objectOutput)
139                    throws IOException {
140                    objectOutput.writeLong(cartId);
141                    objectOutput.writeLong(groupId);
142                    objectOutput.writeLong(companyId);
143                    objectOutput.writeLong(userId);
144    
145                    if (userName == null) {
146                            objectOutput.writeUTF(StringPool.BLANK);
147                    }
148                    else {
149                            objectOutput.writeUTF(userName);
150                    }
151    
152                    objectOutput.writeLong(createDate);
153                    objectOutput.writeLong(modifiedDate);
154    
155                    if (itemIds == null) {
156                            objectOutput.writeUTF(StringPool.BLANK);
157                    }
158                    else {
159                            objectOutput.writeUTF(itemIds);
160                    }
161    
162                    if (couponCodes == null) {
163                            objectOutput.writeUTF(StringPool.BLANK);
164                    }
165                    else {
166                            objectOutput.writeUTF(couponCodes);
167                    }
168    
169                    objectOutput.writeInt(altShipping);
170                    objectOutput.writeBoolean(insure);
171            }
172    
173            public long cartId;
174            public long groupId;
175            public long companyId;
176            public long userId;
177            public String userName;
178            public long createDate;
179            public long modifiedDate;
180            public String itemIds;
181            public String couponCodes;
182            public int altShipping;
183            public boolean insure;
184    }