001    /**
002     * Copyright (c) 2000-2013 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.Shard;
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 Shard in entity cache.
029     *
030     * @author Brian Wing Shun Chan
031     * @see Shard
032     * @generated
033     */
034    public class ShardCacheModel implements CacheModel<Shard>, Externalizable {
035            @Override
036            public String toString() {
037                    StringBundler sb = new StringBundler(9);
038    
039                    sb.append("{shardId=");
040                    sb.append(shardId);
041                    sb.append(", classNameId=");
042                    sb.append(classNameId);
043                    sb.append(", classPK=");
044                    sb.append(classPK);
045                    sb.append(", name=");
046                    sb.append(name);
047                    sb.append("}");
048    
049                    return sb.toString();
050            }
051    
052            @Override
053            public Shard toEntityModel() {
054                    ShardImpl shardImpl = new ShardImpl();
055    
056                    shardImpl.setShardId(shardId);
057                    shardImpl.setClassNameId(classNameId);
058                    shardImpl.setClassPK(classPK);
059    
060                    if (name == null) {
061                            shardImpl.setName(StringPool.BLANK);
062                    }
063                    else {
064                            shardImpl.setName(name);
065                    }
066    
067                    shardImpl.resetOriginalValues();
068    
069                    return shardImpl;
070            }
071    
072            @Override
073            public void readExternal(ObjectInput objectInput) throws IOException {
074                    shardId = objectInput.readLong();
075                    classNameId = objectInput.readLong();
076                    classPK = objectInput.readLong();
077                    name = objectInput.readUTF();
078            }
079    
080            @Override
081            public void writeExternal(ObjectOutput objectOutput)
082                    throws IOException {
083                    objectOutput.writeLong(shardId);
084                    objectOutput.writeLong(classNameId);
085                    objectOutput.writeLong(classPK);
086    
087                    if (name == null) {
088                            objectOutput.writeUTF(StringPool.BLANK);
089                    }
090                    else {
091                            objectOutput.writeUTF(name);
092                    }
093            }
094    
095            public long shardId;
096            public long classNameId;
097            public long classPK;
098            public String name;
099    }