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.HashUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.CacheModel;
023    
024    import com.liferay.portlet.shopping.model.ShoppingItemField;
025    
026    import java.io.Externalizable;
027    import java.io.IOException;
028    import java.io.ObjectInput;
029    import java.io.ObjectOutput;
030    
031    /**
032     * The cache model class for representing ShoppingItemField in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see ShoppingItemField
036     * @generated
037     */
038    @ProviderType
039    public class ShoppingItemFieldCacheModel implements CacheModel<ShoppingItemField>,
040            Externalizable {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof ShoppingItemFieldCacheModel)) {
048                            return false;
049                    }
050    
051                    ShoppingItemFieldCacheModel shoppingItemFieldCacheModel = (ShoppingItemFieldCacheModel)obj;
052    
053                    if (itemFieldId == shoppingItemFieldCacheModel.itemFieldId) {
054                            return true;
055                    }
056    
057                    return false;
058            }
059    
060            @Override
061            public int hashCode() {
062                    return HashUtil.hash(0, itemFieldId);
063            }
064    
065            @Override
066            public String toString() {
067                    StringBundler sb = new StringBundler(11);
068    
069                    sb.append("{itemFieldId=");
070                    sb.append(itemFieldId);
071                    sb.append(", itemId=");
072                    sb.append(itemId);
073                    sb.append(", name=");
074                    sb.append(name);
075                    sb.append(", values=");
076                    sb.append(values);
077                    sb.append(", description=");
078                    sb.append(description);
079                    sb.append("}");
080    
081                    return sb.toString();
082            }
083    
084            @Override
085            public ShoppingItemField toEntityModel() {
086                    ShoppingItemFieldImpl shoppingItemFieldImpl = new ShoppingItemFieldImpl();
087    
088                    shoppingItemFieldImpl.setItemFieldId(itemFieldId);
089                    shoppingItemFieldImpl.setItemId(itemId);
090    
091                    if (name == null) {
092                            shoppingItemFieldImpl.setName(StringPool.BLANK);
093                    }
094                    else {
095                            shoppingItemFieldImpl.setName(name);
096                    }
097    
098                    if (values == null) {
099                            shoppingItemFieldImpl.setValues(StringPool.BLANK);
100                    }
101                    else {
102                            shoppingItemFieldImpl.setValues(values);
103                    }
104    
105                    if (description == null) {
106                            shoppingItemFieldImpl.setDescription(StringPool.BLANK);
107                    }
108                    else {
109                            shoppingItemFieldImpl.setDescription(description);
110                    }
111    
112                    shoppingItemFieldImpl.resetOriginalValues();
113    
114                    return shoppingItemFieldImpl;
115            }
116    
117            @Override
118            public void readExternal(ObjectInput objectInput) throws IOException {
119                    itemFieldId = objectInput.readLong();
120                    itemId = objectInput.readLong();
121                    name = objectInput.readUTF();
122                    values = objectInput.readUTF();
123                    description = objectInput.readUTF();
124            }
125    
126            @Override
127            public void writeExternal(ObjectOutput objectOutput)
128                    throws IOException {
129                    objectOutput.writeLong(itemFieldId);
130                    objectOutput.writeLong(itemId);
131    
132                    if (name == null) {
133                            objectOutput.writeUTF(StringPool.BLANK);
134                    }
135                    else {
136                            objectOutput.writeUTF(name);
137                    }
138    
139                    if (values == null) {
140                            objectOutput.writeUTF(StringPool.BLANK);
141                    }
142                    else {
143                            objectOutput.writeUTF(values);
144                    }
145    
146                    if (description == null) {
147                            objectOutput.writeUTF(StringPool.BLANK);
148                    }
149                    else {
150                            objectOutput.writeUTF(description);
151                    }
152            }
153    
154            public long itemFieldId;
155            public long itemId;
156            public String name;
157            public String values;
158            public String description;
159    }