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.portal.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.model.CacheModel;
020    import com.liferay.portal.kernel.model.Country;
021    import com.liferay.portal.kernel.model.MVCCModel;
022    import com.liferay.portal.kernel.util.HashUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
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 Country in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see Country
036     * @generated
037     */
038    @ProviderType
039    public class CountryCacheModel implements CacheModel<Country>, Externalizable,
040            MVCCModel {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof CountryCacheModel)) {
048                            return false;
049                    }
050    
051                    CountryCacheModel countryCacheModel = (CountryCacheModel)obj;
052    
053                    if ((countryId == countryCacheModel.countryId) &&
054                                    (mvccVersion == countryCacheModel.mvccVersion)) {
055                            return true;
056                    }
057    
058                    return false;
059            }
060    
061            @Override
062            public int hashCode() {
063                    int hashCode = HashUtil.hash(0, countryId);
064    
065                    return HashUtil.hash(hashCode, mvccVersion);
066            }
067    
068            @Override
069            public long getMvccVersion() {
070                    return mvccVersion;
071            }
072    
073            @Override
074            public void setMvccVersion(long mvccVersion) {
075                    this.mvccVersion = mvccVersion;
076            }
077    
078            @Override
079            public String toString() {
080                    StringBundler sb = new StringBundler(19);
081    
082                    sb.append("{mvccVersion=");
083                    sb.append(mvccVersion);
084                    sb.append(", countryId=");
085                    sb.append(countryId);
086                    sb.append(", name=");
087                    sb.append(name);
088                    sb.append(", a2=");
089                    sb.append(a2);
090                    sb.append(", a3=");
091                    sb.append(a3);
092                    sb.append(", number=");
093                    sb.append(number);
094                    sb.append(", idd=");
095                    sb.append(idd);
096                    sb.append(", zipRequired=");
097                    sb.append(zipRequired);
098                    sb.append(", active=");
099                    sb.append(active);
100                    sb.append("}");
101    
102                    return sb.toString();
103            }
104    
105            @Override
106            public Country toEntityModel() {
107                    CountryImpl countryImpl = new CountryImpl();
108    
109                    countryImpl.setMvccVersion(mvccVersion);
110                    countryImpl.setCountryId(countryId);
111    
112                    if (name == null) {
113                            countryImpl.setName(StringPool.BLANK);
114                    }
115                    else {
116                            countryImpl.setName(name);
117                    }
118    
119                    if (a2 == null) {
120                            countryImpl.setA2(StringPool.BLANK);
121                    }
122                    else {
123                            countryImpl.setA2(a2);
124                    }
125    
126                    if (a3 == null) {
127                            countryImpl.setA3(StringPool.BLANK);
128                    }
129                    else {
130                            countryImpl.setA3(a3);
131                    }
132    
133                    if (number == null) {
134                            countryImpl.setNumber(StringPool.BLANK);
135                    }
136                    else {
137                            countryImpl.setNumber(number);
138                    }
139    
140                    if (idd == null) {
141                            countryImpl.setIdd(StringPool.BLANK);
142                    }
143                    else {
144                            countryImpl.setIdd(idd);
145                    }
146    
147                    countryImpl.setZipRequired(zipRequired);
148                    countryImpl.setActive(active);
149    
150                    countryImpl.resetOriginalValues();
151    
152                    return countryImpl;
153            }
154    
155            @Override
156            public void readExternal(ObjectInput objectInput) throws IOException {
157                    mvccVersion = objectInput.readLong();
158    
159                    countryId = objectInput.readLong();
160                    name = objectInput.readUTF();
161                    a2 = objectInput.readUTF();
162                    a3 = objectInput.readUTF();
163                    number = objectInput.readUTF();
164                    idd = objectInput.readUTF();
165    
166                    zipRequired = objectInput.readBoolean();
167    
168                    active = objectInput.readBoolean();
169            }
170    
171            @Override
172            public void writeExternal(ObjectOutput objectOutput)
173                    throws IOException {
174                    objectOutput.writeLong(mvccVersion);
175    
176                    objectOutput.writeLong(countryId);
177    
178                    if (name == null) {
179                            objectOutput.writeUTF(StringPool.BLANK);
180                    }
181                    else {
182                            objectOutput.writeUTF(name);
183                    }
184    
185                    if (a2 == null) {
186                            objectOutput.writeUTF(StringPool.BLANK);
187                    }
188                    else {
189                            objectOutput.writeUTF(a2);
190                    }
191    
192                    if (a3 == null) {
193                            objectOutput.writeUTF(StringPool.BLANK);
194                    }
195                    else {
196                            objectOutput.writeUTF(a3);
197                    }
198    
199                    if (number == null) {
200                            objectOutput.writeUTF(StringPool.BLANK);
201                    }
202                    else {
203                            objectOutput.writeUTF(number);
204                    }
205    
206                    if (idd == null) {
207                            objectOutput.writeUTF(StringPool.BLANK);
208                    }
209                    else {
210                            objectOutput.writeUTF(idd);
211                    }
212    
213                    objectOutput.writeBoolean(zipRequired);
214    
215                    objectOutput.writeBoolean(active);
216            }
217    
218            public long mvccVersion;
219            public long countryId;
220            public String name;
221            public String a2;
222            public String a3;
223            public String number;
224            public String idd;
225            public boolean zipRequired;
226            public boolean active;
227    }