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.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            public Counter toEntityModel() {
050                    CounterImpl counterImpl = new CounterImpl();
051    
052                    if (name == null) {
053                            counterImpl.setName(StringPool.BLANK);
054                    }
055                    else {
056                            counterImpl.setName(name);
057                    }
058    
059                    counterImpl.setCurrentId(currentId);
060    
061                    counterImpl.resetOriginalValues();
062    
063                    return counterImpl;
064            }
065    
066            public void readExternal(ObjectInput objectInput) throws IOException {
067                    name = objectInput.readUTF();
068                    currentId = objectInput.readLong();
069            }
070    
071            public void writeExternal(ObjectOutput objectOutput)
072                    throws IOException {
073                    if (name == null) {
074                            objectOutput.writeUTF(StringPool.BLANK);
075                    }
076                    else {
077                            objectOutput.writeUTF(name);
078                    }
079    
080                    objectOutput.writeLong(currentId);
081            }
082    
083            public String name;
084            public long currentId;
085    }