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.ShoppingOrderItem;
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 ShoppingOrderItem in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see ShoppingOrderItem
035     * @generated
036     */
037    public class ShoppingOrderItemCacheModel implements CacheModel<ShoppingOrderItem>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(21);
042    
043                    sb.append("{orderItemId=");
044                    sb.append(orderItemId);
045                    sb.append(", orderId=");
046                    sb.append(orderId);
047                    sb.append(", itemId=");
048                    sb.append(itemId);
049                    sb.append(", sku=");
050                    sb.append(sku);
051                    sb.append(", name=");
052                    sb.append(name);
053                    sb.append(", description=");
054                    sb.append(description);
055                    sb.append(", properties=");
056                    sb.append(properties);
057                    sb.append(", price=");
058                    sb.append(price);
059                    sb.append(", quantity=");
060                    sb.append(quantity);
061                    sb.append(", shippedDate=");
062                    sb.append(shippedDate);
063                    sb.append("}");
064    
065                    return sb.toString();
066            }
067    
068            @Override
069            public ShoppingOrderItem toEntityModel() {
070                    ShoppingOrderItemImpl shoppingOrderItemImpl = new ShoppingOrderItemImpl();
071    
072                    shoppingOrderItemImpl.setOrderItemId(orderItemId);
073                    shoppingOrderItemImpl.setOrderId(orderId);
074    
075                    if (itemId == null) {
076                            shoppingOrderItemImpl.setItemId(StringPool.BLANK);
077                    }
078                    else {
079                            shoppingOrderItemImpl.setItemId(itemId);
080                    }
081    
082                    if (sku == null) {
083                            shoppingOrderItemImpl.setSku(StringPool.BLANK);
084                    }
085                    else {
086                            shoppingOrderItemImpl.setSku(sku);
087                    }
088    
089                    if (name == null) {
090                            shoppingOrderItemImpl.setName(StringPool.BLANK);
091                    }
092                    else {
093                            shoppingOrderItemImpl.setName(name);
094                    }
095    
096                    if (description == null) {
097                            shoppingOrderItemImpl.setDescription(StringPool.BLANK);
098                    }
099                    else {
100                            shoppingOrderItemImpl.setDescription(description);
101                    }
102    
103                    if (properties == null) {
104                            shoppingOrderItemImpl.setProperties(StringPool.BLANK);
105                    }
106                    else {
107                            shoppingOrderItemImpl.setProperties(properties);
108                    }
109    
110                    shoppingOrderItemImpl.setPrice(price);
111                    shoppingOrderItemImpl.setQuantity(quantity);
112    
113                    if (shippedDate == Long.MIN_VALUE) {
114                            shoppingOrderItemImpl.setShippedDate(null);
115                    }
116                    else {
117                            shoppingOrderItemImpl.setShippedDate(new Date(shippedDate));
118                    }
119    
120                    shoppingOrderItemImpl.resetOriginalValues();
121    
122                    return shoppingOrderItemImpl;
123            }
124    
125            @Override
126            public void readExternal(ObjectInput objectInput) throws IOException {
127                    orderItemId = objectInput.readLong();
128                    orderId = objectInput.readLong();
129                    itemId = objectInput.readUTF();
130                    sku = objectInput.readUTF();
131                    name = objectInput.readUTF();
132                    description = objectInput.readUTF();
133                    properties = objectInput.readUTF();
134                    price = objectInput.readDouble();
135                    quantity = objectInput.readInt();
136                    shippedDate = objectInput.readLong();
137            }
138    
139            @Override
140            public void writeExternal(ObjectOutput objectOutput)
141                    throws IOException {
142                    objectOutput.writeLong(orderItemId);
143                    objectOutput.writeLong(orderId);
144    
145                    if (itemId == null) {
146                            objectOutput.writeUTF(StringPool.BLANK);
147                    }
148                    else {
149                            objectOutput.writeUTF(itemId);
150                    }
151    
152                    if (sku == null) {
153                            objectOutput.writeUTF(StringPool.BLANK);
154                    }
155                    else {
156                            objectOutput.writeUTF(sku);
157                    }
158    
159                    if (name == null) {
160                            objectOutput.writeUTF(StringPool.BLANK);
161                    }
162                    else {
163                            objectOutput.writeUTF(name);
164                    }
165    
166                    if (description == null) {
167                            objectOutput.writeUTF(StringPool.BLANK);
168                    }
169                    else {
170                            objectOutput.writeUTF(description);
171                    }
172    
173                    if (properties == null) {
174                            objectOutput.writeUTF(StringPool.BLANK);
175                    }
176                    else {
177                            objectOutput.writeUTF(properties);
178                    }
179    
180                    objectOutput.writeDouble(price);
181                    objectOutput.writeInt(quantity);
182                    objectOutput.writeLong(shippedDate);
183            }
184    
185            public long orderItemId;
186            public long orderId;
187            public String itemId;
188            public String sku;
189            public String name;
190            public String description;
191            public String properties;
192            public double price;
193            public int quantity;
194            public long shippedDate;
195    }