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.ShoppingItemField;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    /**
029     * The cache model class for representing ShoppingItemField in entity cache.
030     *
031     * @author Brian Wing Shun Chan
032     * @see ShoppingItemField
033     * @generated
034     */
035    public class ShoppingItemFieldCacheModel implements CacheModel<ShoppingItemField>,
036            Externalizable {
037            @Override
038            public String toString() {
039                    StringBundler sb = new StringBundler(11);
040    
041                    sb.append("{itemFieldId=");
042                    sb.append(itemFieldId);
043                    sb.append(", itemId=");
044                    sb.append(itemId);
045                    sb.append(", name=");
046                    sb.append(name);
047                    sb.append(", values=");
048                    sb.append(values);
049                    sb.append(", description=");
050                    sb.append(description);
051                    sb.append("}");
052    
053                    return sb.toString();
054            }
055    
056            @Override
057            public ShoppingItemField toEntityModel() {
058                    ShoppingItemFieldImpl shoppingItemFieldImpl = new ShoppingItemFieldImpl();
059    
060                    shoppingItemFieldImpl.setItemFieldId(itemFieldId);
061                    shoppingItemFieldImpl.setItemId(itemId);
062    
063                    if (name == null) {
064                            shoppingItemFieldImpl.setName(StringPool.BLANK);
065                    }
066                    else {
067                            shoppingItemFieldImpl.setName(name);
068                    }
069    
070                    if (values == null) {
071                            shoppingItemFieldImpl.setValues(StringPool.BLANK);
072                    }
073                    else {
074                            shoppingItemFieldImpl.setValues(values);
075                    }
076    
077                    if (description == null) {
078                            shoppingItemFieldImpl.setDescription(StringPool.BLANK);
079                    }
080                    else {
081                            shoppingItemFieldImpl.setDescription(description);
082                    }
083    
084                    shoppingItemFieldImpl.resetOriginalValues();
085    
086                    return shoppingItemFieldImpl;
087            }
088    
089            @Override
090            public void readExternal(ObjectInput objectInput) throws IOException {
091                    itemFieldId = objectInput.readLong();
092                    itemId = objectInput.readLong();
093                    name = objectInput.readUTF();
094                    values = objectInput.readUTF();
095                    description = objectInput.readUTF();
096            }
097    
098            @Override
099            public void writeExternal(ObjectOutput objectOutput)
100                    throws IOException {
101                    objectOutput.writeLong(itemFieldId);
102                    objectOutput.writeLong(itemId);
103    
104                    if (name == null) {
105                            objectOutput.writeUTF(StringPool.BLANK);
106                    }
107                    else {
108                            objectOutput.writeUTF(name);
109                    }
110    
111                    if (values == null) {
112                            objectOutput.writeUTF(StringPool.BLANK);
113                    }
114                    else {
115                            objectOutput.writeUTF(values);
116                    }
117    
118                    if (description == null) {
119                            objectOutput.writeUTF(StringPool.BLANK);
120                    }
121                    else {
122                            objectOutput.writeUTF(description);
123                    }
124            }
125    
126            public long itemFieldId;
127            public long itemId;
128            public String name;
129            public String values;
130            public String description;
131    }