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