001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.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    import com.liferay.portal.model.Region;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    /**
028     * The cache model class for representing Region in entity cache.
029     *
030     * @author Brian Wing Shun Chan
031     * @see Region
032     * @generated
033     */
034    public class RegionCacheModel implements CacheModel<Region>, Externalizable {
035            @Override
036            public String toString() {
037                    StringBundler sb = new StringBundler(11);
038    
039                    sb.append("{regionId=");
040                    sb.append(regionId);
041                    sb.append(", countryId=");
042                    sb.append(countryId);
043                    sb.append(", regionCode=");
044                    sb.append(regionCode);
045                    sb.append(", name=");
046                    sb.append(name);
047                    sb.append(", active=");
048                    sb.append(active);
049                    sb.append("}");
050    
051                    return sb.toString();
052            }
053    
054            @Override
055            public Region toEntityModel() {
056                    RegionImpl regionImpl = new RegionImpl();
057    
058                    regionImpl.setRegionId(regionId);
059                    regionImpl.setCountryId(countryId);
060    
061                    if (regionCode == null) {
062                            regionImpl.setRegionCode(StringPool.BLANK);
063                    }
064                    else {
065                            regionImpl.setRegionCode(regionCode);
066                    }
067    
068                    if (name == null) {
069                            regionImpl.setName(StringPool.BLANK);
070                    }
071                    else {
072                            regionImpl.setName(name);
073                    }
074    
075                    regionImpl.setActive(active);
076    
077                    regionImpl.resetOriginalValues();
078    
079                    return regionImpl;
080            }
081    
082            @Override
083            public void readExternal(ObjectInput objectInput) throws IOException {
084                    regionId = objectInput.readLong();
085                    countryId = objectInput.readLong();
086                    regionCode = objectInput.readUTF();
087                    name = objectInput.readUTF();
088                    active = objectInput.readBoolean();
089            }
090    
091            @Override
092            public void writeExternal(ObjectOutput objectOutput)
093                    throws IOException {
094                    objectOutput.writeLong(regionId);
095                    objectOutput.writeLong(countryId);
096    
097                    if (regionCode == null) {
098                            objectOutput.writeUTF(StringPool.BLANK);
099                    }
100                    else {
101                            objectOutput.writeUTF(regionCode);
102                    }
103    
104                    if (name == null) {
105                            objectOutput.writeUTF(StringPool.BLANK);
106                    }
107                    else {
108                            objectOutput.writeUTF(name);
109                    }
110    
111                    objectOutput.writeBoolean(active);
112            }
113    
114            public long regionId;
115            public long countryId;
116            public String regionCode;
117            public String name;
118            public boolean active;
119    }