001    /**
002     * Copyright (c) 2000-2012 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            public ShoppingItemField toEntityModel() {
057                    ShoppingItemFieldImpl shoppingItemFieldImpl = new ShoppingItemFieldImpl();
058    
059                    shoppingItemFieldImpl.setItemFieldId(itemFieldId);
060                    shoppingItemFieldImpl.setItemId(itemId);
061    
062                    if (name == null) {
063                            shoppingItemFieldImpl.setName(StringPool.BLANK);
064                    }
065                    else {
066                            shoppingItemFieldImpl.setName(name);
067                    }
068    
069                    if (values == null) {
070                            shoppingItemFieldImpl.setValues(StringPool.BLANK);
071                    }
072                    else {
073                            shoppingItemFieldImpl.setValues(values);
074                    }
075    
076                    if (description == null) {
077                            shoppingItemFieldImpl.setDescription(StringPool.BLANK);
078                    }
079                    else {
080                            shoppingItemFieldImpl.setDescription(description);
081                    }
082    
083                    shoppingItemFieldImpl.resetOriginalValues();
084    
085                    return shoppingItemFieldImpl;
086            }
087    
088            public void readExternal(ObjectInput objectInput) throws IOException {
089                    itemFieldId = objectInput.readLong();
090                    itemId = objectInput.readLong();
091                    name = objectInput.readUTF();
092                    values = objectInput.readUTF();
093                    description = objectInput.readUTF();
094            }
095    
096            public void writeExternal(ObjectOutput objectOutput)
097                    throws IOException {
098                    objectOutput.writeLong(itemFieldId);
099                    objectOutput.writeLong(itemId);
100    
101                    if (name == null) {
102                            objectOutput.writeUTF(StringPool.BLANK);
103                    }
104                    else {
105                            objectOutput.writeUTF(name);
106                    }
107    
108                    if (values == null) {
109                            objectOutput.writeUTF(StringPool.BLANK);
110                    }
111                    else {
112                            objectOutput.writeUTF(values);
113                    }
114    
115                    if (description == null) {
116                            objectOutput.writeUTF(StringPool.BLANK);
117                    }
118                    else {
119                            objectOutput.writeUTF(description);
120                    }
121            }
122    
123            public long itemFieldId;
124            public long itemId;
125            public String name;
126            public String values;
127            public String description;
128    }