001    /**
002     * Copyright (c) 2000-2012 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 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            public Region toEntityModel() {
055                    RegionImpl regionImpl = new RegionImpl();
056    
057                    regionImpl.setRegionId(regionId);
058                    regionImpl.setCountryId(countryId);
059    
060                    if (regionCode == null) {
061                            regionImpl.setRegionCode(StringPool.BLANK);
062                    }
063                    else {
064                            regionImpl.setRegionCode(regionCode);
065                    }
066    
067                    if (name == null) {
068                            regionImpl.setName(StringPool.BLANK);
069                    }
070                    else {
071                            regionImpl.setName(name);
072                    }
073    
074                    regionImpl.setActive(active);
075    
076                    regionImpl.resetOriginalValues();
077    
078                    return regionImpl;
079            }
080    
081            public void readExternal(ObjectInput objectInput) throws IOException {
082                    regionId = objectInput.readLong();
083                    countryId = objectInput.readLong();
084                    regionCode = objectInput.readUTF();
085                    name = objectInput.readUTF();
086                    active = objectInput.readBoolean();
087            }
088    
089            public void writeExternal(ObjectOutput objectOutput)
090                    throws IOException {
091                    objectOutput.writeLong(regionId);
092                    objectOutput.writeLong(countryId);
093    
094                    if (regionCode == null) {
095                            objectOutput.writeUTF(StringPool.BLANK);
096                    }
097                    else {
098                            objectOutput.writeUTF(regionCode);
099                    }
100    
101                    if (name == null) {
102                            objectOutput.writeUTF(StringPool.BLANK);
103                    }
104                    else {
105                            objectOutput.writeUTF(name);
106                    }
107    
108                    objectOutput.writeBoolean(active);
109            }
110    
111            public long regionId;
112            public long countryId;
113            public String regionCode;
114            public String name;
115            public boolean active;
116    }