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.portal.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.util.HashUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.CacheModel;
023    import com.liferay.portal.model.ListType;
024    import com.liferay.portal.model.MVCCModel;
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 ListType in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see ListType
036     * @generated
037     */
038    @ProviderType
039    public class ListTypeCacheModel implements CacheModel<ListType>, Externalizable,
040            MVCCModel {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof ListTypeCacheModel)) {
048                            return false;
049                    }
050    
051                    ListTypeCacheModel listTypeCacheModel = (ListTypeCacheModel)obj;
052    
053                    if ((listTypeId == listTypeCacheModel.listTypeId) &&
054                                    (mvccVersion == listTypeCacheModel.mvccVersion)) {
055                            return true;
056                    }
057    
058                    return false;
059            }
060    
061            @Override
062            public int hashCode() {
063                    int hashCode = HashUtil.hash(0, listTypeId);
064    
065                    return HashUtil.hash(hashCode, mvccVersion);
066            }
067    
068            @Override
069            public long getMvccVersion() {
070                    return mvccVersion;
071            }
072    
073            @Override
074            public void setMvccVersion(long mvccVersion) {
075                    this.mvccVersion = mvccVersion;
076            }
077    
078            @Override
079            public String toString() {
080                    StringBundler sb = new StringBundler(9);
081    
082                    sb.append("{mvccVersion=");
083                    sb.append(mvccVersion);
084                    sb.append(", listTypeId=");
085                    sb.append(listTypeId);
086                    sb.append(", name=");
087                    sb.append(name);
088                    sb.append(", type=");
089                    sb.append(type);
090                    sb.append("}");
091    
092                    return sb.toString();
093            }
094    
095            @Override
096            public ListType toEntityModel() {
097                    ListTypeImpl listTypeImpl = new ListTypeImpl();
098    
099                    listTypeImpl.setMvccVersion(mvccVersion);
100                    listTypeImpl.setListTypeId(listTypeId);
101    
102                    if (name == null) {
103                            listTypeImpl.setName(StringPool.BLANK);
104                    }
105                    else {
106                            listTypeImpl.setName(name);
107                    }
108    
109                    if (type == null) {
110                            listTypeImpl.setType(StringPool.BLANK);
111                    }
112                    else {
113                            listTypeImpl.setType(type);
114                    }
115    
116                    listTypeImpl.resetOriginalValues();
117    
118                    return listTypeImpl;
119            }
120    
121            @Override
122            public void readExternal(ObjectInput objectInput) throws IOException {
123                    mvccVersion = objectInput.readLong();
124                    listTypeId = objectInput.readLong();
125                    name = objectInput.readUTF();
126                    type = objectInput.readUTF();
127            }
128    
129            @Override
130            public void writeExternal(ObjectOutput objectOutput)
131                    throws IOException {
132                    objectOutput.writeLong(mvccVersion);
133                    objectOutput.writeLong(listTypeId);
134    
135                    if (name == null) {
136                            objectOutput.writeUTF(StringPool.BLANK);
137                    }
138                    else {
139                            objectOutput.writeUTF(name);
140                    }
141    
142                    if (type == null) {
143                            objectOutput.writeUTF(StringPool.BLANK);
144                    }
145                    else {
146                            objectOutput.writeUTF(type);
147                    }
148            }
149    
150            public long mvccVersion;
151            public long listTypeId;
152            public String name;
153            public String type;
154    }