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