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.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.CacheModel;
022    import com.liferay.portal.model.MVCCModel;
023    import com.liferay.portal.model.Region;
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 Region in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see Region
035     * @generated
036     */
037    @ProviderType
038    public class RegionCacheModel implements CacheModel<Region>, Externalizable,
039            MVCCModel {
040            @Override
041            public long getMvccVersion() {
042                    return mvccVersion;
043            }
044    
045            @Override
046            public void setMvccVersion(long mvccVersion) {
047                    this.mvccVersion = mvccVersion;
048            }
049    
050            @Override
051            public String toString() {
052                    StringBundler sb = new StringBundler(13);
053    
054                    sb.append("{mvccVersion=");
055                    sb.append(mvccVersion);
056                    sb.append(", regionId=");
057                    sb.append(regionId);
058                    sb.append(", countryId=");
059                    sb.append(countryId);
060                    sb.append(", regionCode=");
061                    sb.append(regionCode);
062                    sb.append(", name=");
063                    sb.append(name);
064                    sb.append(", active=");
065                    sb.append(active);
066                    sb.append("}");
067    
068                    return sb.toString();
069            }
070    
071            @Override
072            public Region toEntityModel() {
073                    RegionImpl regionImpl = new RegionImpl();
074    
075                    regionImpl.setMvccVersion(mvccVersion);
076                    regionImpl.setRegionId(regionId);
077                    regionImpl.setCountryId(countryId);
078    
079                    if (regionCode == null) {
080                            regionImpl.setRegionCode(StringPool.BLANK);
081                    }
082                    else {
083                            regionImpl.setRegionCode(regionCode);
084                    }
085    
086                    if (name == null) {
087                            regionImpl.setName(StringPool.BLANK);
088                    }
089                    else {
090                            regionImpl.setName(name);
091                    }
092    
093                    regionImpl.setActive(active);
094    
095                    regionImpl.resetOriginalValues();
096    
097                    return regionImpl;
098            }
099    
100            @Override
101            public void readExternal(ObjectInput objectInput) throws IOException {
102                    mvccVersion = objectInput.readLong();
103                    regionId = objectInput.readLong();
104                    countryId = objectInput.readLong();
105                    regionCode = objectInput.readUTF();
106                    name = objectInput.readUTF();
107                    active = objectInput.readBoolean();
108            }
109    
110            @Override
111            public void writeExternal(ObjectOutput objectOutput)
112                    throws IOException {
113                    objectOutput.writeLong(mvccVersion);
114                    objectOutput.writeLong(regionId);
115                    objectOutput.writeLong(countryId);
116    
117                    if (regionCode == null) {
118                            objectOutput.writeUTF(StringPool.BLANK);
119                    }
120                    else {
121                            objectOutput.writeUTF(regionCode);
122                    }
123    
124                    if (name == null) {
125                            objectOutput.writeUTF(StringPool.BLANK);
126                    }
127                    else {
128                            objectOutput.writeUTF(name);
129                    }
130    
131                    objectOutput.writeBoolean(active);
132            }
133    
134            public long mvccVersion;
135            public long regionId;
136            public long countryId;
137            public String regionCode;
138            public String name;
139            public boolean active;
140    }