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