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            public ShoppingCart toEntityModel() {
071                    ShoppingCartImpl shoppingCartImpl = new ShoppingCartImpl();
072    
073                    shoppingCartImpl.setCartId(cartId);
074                    shoppingCartImpl.setGroupId(groupId);
075                    shoppingCartImpl.setCompanyId(companyId);
076                    shoppingCartImpl.setUserId(userId);
077    
078                    if (userName == null) {
079                            shoppingCartImpl.setUserName(StringPool.BLANK);
080                    }
081                    else {
082                            shoppingCartImpl.setUserName(userName);
083                    }
084    
085                    if (createDate == Long.MIN_VALUE) {
086                            shoppingCartImpl.setCreateDate(null);
087                    }
088                    else {
089                            shoppingCartImpl.setCreateDate(new Date(createDate));
090                    }
091    
092                    if (modifiedDate == Long.MIN_VALUE) {
093                            shoppingCartImpl.setModifiedDate(null);
094                    }
095                    else {
096                            shoppingCartImpl.setModifiedDate(new Date(modifiedDate));
097                    }
098    
099                    if (itemIds == null) {
100                            shoppingCartImpl.setItemIds(StringPool.BLANK);
101                    }
102                    else {
103                            shoppingCartImpl.setItemIds(itemIds);
104                    }
105    
106                    if (couponCodes == null) {
107                            shoppingCartImpl.setCouponCodes(StringPool.BLANK);
108                    }
109                    else {
110                            shoppingCartImpl.setCouponCodes(couponCodes);
111                    }
112    
113                    shoppingCartImpl.setAltShipping(altShipping);
114                    shoppingCartImpl.setInsure(insure);
115    
116                    shoppingCartImpl.resetOriginalValues();
117    
118                    return shoppingCartImpl;
119            }
120    
121            public void readExternal(ObjectInput objectInput) throws IOException {
122                    cartId = objectInput.readLong();
123                    groupId = objectInput.readLong();
124                    companyId = objectInput.readLong();
125                    userId = objectInput.readLong();
126                    userName = objectInput.readUTF();
127                    createDate = objectInput.readLong();
128                    modifiedDate = objectInput.readLong();
129                    itemIds = objectInput.readUTF();
130                    couponCodes = objectInput.readUTF();
131                    altShipping = objectInput.readInt();
132                    insure = objectInput.readBoolean();
133            }
134    
135            public void writeExternal(ObjectOutput objectOutput)
136                    throws IOException {
137                    objectOutput.writeLong(cartId);
138                    objectOutput.writeLong(groupId);
139                    objectOutput.writeLong(companyId);
140                    objectOutput.writeLong(userId);
141    
142                    if (userName == null) {
143                            objectOutput.writeUTF(StringPool.BLANK);
144                    }
145                    else {
146                            objectOutput.writeUTF(userName);
147                    }
148    
149                    objectOutput.writeLong(createDate);
150                    objectOutput.writeLong(modifiedDate);
151    
152                    if (itemIds == null) {
153                            objectOutput.writeUTF(StringPool.BLANK);
154                    }
155                    else {
156                            objectOutput.writeUTF(itemIds);
157                    }
158    
159                    if (couponCodes == null) {
160                            objectOutput.writeUTF(StringPool.BLANK);
161                    }
162                    else {
163                            objectOutput.writeUTF(couponCodes);
164                    }
165    
166                    objectOutput.writeInt(altShipping);
167                    objectOutput.writeBoolean(insure);
168            }
169    
170            public long cartId;
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 String itemIds;
178            public String couponCodes;
179            public int altShipping;
180            public boolean insure;
181    }