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            public Shard toEntityModel() {
053                    ShardImpl shardImpl = new ShardImpl();
054    
055                    shardImpl.setShardId(shardId);
056                    shardImpl.setClassNameId(classNameId);
057                    shardImpl.setClassPK(classPK);
058    
059                    if (name == null) {
060                            shardImpl.setName(StringPool.BLANK);
061                    }
062                    else {
063                            shardImpl.setName(name);
064                    }
065    
066                    shardImpl.resetOriginalValues();
067    
068                    return shardImpl;
069            }
070    
071            public void readExternal(ObjectInput objectInput) throws IOException {
072                    shardId = objectInput.readLong();
073                    classNameId = objectInput.readLong();
074                    classPK = objectInput.readLong();
075                    name = objectInput.readUTF();
076            }
077    
078            public void writeExternal(ObjectOutput objectOutput)
079                    throws IOException {
080                    objectOutput.writeLong(shardId);
081                    objectOutput.writeLong(classNameId);
082                    objectOutput.writeLong(classPK);
083    
084                    if (name == null) {
085                            objectOutput.writeUTF(StringPool.BLANK);
086                    }
087                    else {
088                            objectOutput.writeUTF(name);
089                    }
090            }
091    
092            public long shardId;
093            public long classNameId;
094            public long classPK;
095            public String name;
096    }