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.counter.model.impl;
016    
017    import com.liferay.counter.model.Counter;
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    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    /**
029     * The cache model class for representing Counter in entity cache.
030     *
031     * @author Brian Wing Shun Chan
032     * @see Counter
033     * @generated
034     */
035    public class CounterCacheModel implements CacheModel<Counter>, Externalizable {
036            @Override
037            public String toString() {
038                    StringBundler sb = new StringBundler(5);
039    
040                    sb.append("{name=");
041                    sb.append(name);
042                    sb.append(", currentId=");
043                    sb.append(currentId);
044                    sb.append("}");
045    
046                    return sb.toString();
047            }
048    
049            @Override
050            public Counter toEntityModel() {
051                    CounterImpl counterImpl = new CounterImpl();
052    
053                    if (name == null) {
054                            counterImpl.setName(StringPool.BLANK);
055                    }
056                    else {
057                            counterImpl.setName(name);
058                    }
059    
060                    counterImpl.setCurrentId(currentId);
061    
062                    counterImpl.resetOriginalValues();
063    
064                    return counterImpl;
065            }
066    
067            @Override
068            public void readExternal(ObjectInput objectInput) throws IOException {
069                    name = objectInput.readUTF();
070                    currentId = objectInput.readLong();
071            }
072    
073            @Override
074            public void writeExternal(ObjectOutput objectOutput)
075                    throws IOException {
076                    if (name == null) {
077                            objectOutput.writeUTF(StringPool.BLANK);
078                    }
079                    else {
080                            objectOutput.writeUTF(name);
081                    }
082    
083                    objectOutput.writeLong(currentId);
084            }
085    
086            public String name;
087            public long currentId;
088    }