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.HashUtil;
022    import com.liferay.portal.kernel.util.StringBundler;
023    import com.liferay.portal.kernel.util.StringPool;
024    import com.liferay.portal.model.CacheModel;
025    
026    import java.io.Externalizable;
027    import java.io.IOException;
028    import java.io.ObjectInput;
029    import java.io.ObjectOutput;
030    
031    /**
032     * The cache model class for representing Counter in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see Counter
036     * @generated
037     */
038    @ProviderType
039    public class CounterCacheModel implements CacheModel<Counter>, Externalizable {
040            @Override
041            public boolean equals(Object obj) {
042                    if (this == obj) {
043                            return true;
044                    }
045    
046                    if (!(obj instanceof CounterCacheModel)) {
047                            return false;
048                    }
049    
050                    CounterCacheModel counterCacheModel = (CounterCacheModel)obj;
051    
052                    if (name.equals(counterCacheModel.name)) {
053                            return true;
054                    }
055    
056                    return false;
057            }
058    
059            @Override
060            public int hashCode() {
061                    return HashUtil.hash(0, name);
062            }
063    
064            @Override
065            public String toString() {
066                    StringBundler sb = new StringBundler(5);
067    
068                    sb.append("{name=");
069                    sb.append(name);
070                    sb.append(", currentId=");
071                    sb.append(currentId);
072                    sb.append("}");
073    
074                    return sb.toString();
075            }
076    
077            @Override
078            public Counter toEntityModel() {
079                    CounterImpl counterImpl = new CounterImpl();
080    
081                    if (name == null) {
082                            counterImpl.setName(StringPool.BLANK);
083                    }
084                    else {
085                            counterImpl.setName(name);
086                    }
087    
088                    counterImpl.setCurrentId(currentId);
089    
090                    counterImpl.resetOriginalValues();
091    
092                    return counterImpl;
093            }
094    
095            @Override
096            public void readExternal(ObjectInput objectInput) throws IOException {
097                    name = objectInput.readUTF();
098                    currentId = objectInput.readLong();
099            }
100    
101            @Override
102            public void writeExternal(ObjectOutput objectOutput)
103                    throws IOException {
104                    if (name == null) {
105                            objectOutput.writeUTF(StringPool.BLANK);
106                    }
107                    else {
108                            objectOutput.writeUTF(name);
109                    }
110    
111                    objectOutput.writeLong(currentId);
112            }
113    
114            public String name;
115            public long currentId;
116    }