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.portlet.trash.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    
024    import com.liferay.portlet.trash.model.TrashVersion;
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 TrashVersion in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see TrashVersion
036     * @generated
037     */
038    @ProviderType
039    public class TrashVersionCacheModel implements CacheModel<TrashVersion>,
040            Externalizable {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof TrashVersionCacheModel)) {
048                            return false;
049                    }
050    
051                    TrashVersionCacheModel trashVersionCacheModel = (TrashVersionCacheModel)obj;
052    
053                    if (versionId == trashVersionCacheModel.versionId) {
054                            return true;
055                    }
056    
057                    return false;
058            }
059    
060            @Override
061            public int hashCode() {
062                    return HashUtil.hash(0, versionId);
063            }
064    
065            @Override
066            public String toString() {
067                    StringBundler sb = new StringBundler(13);
068    
069                    sb.append("{versionId=");
070                    sb.append(versionId);
071                    sb.append(", entryId=");
072                    sb.append(entryId);
073                    sb.append(", classNameId=");
074                    sb.append(classNameId);
075                    sb.append(", classPK=");
076                    sb.append(classPK);
077                    sb.append(", typeSettings=");
078                    sb.append(typeSettings);
079                    sb.append(", status=");
080                    sb.append(status);
081                    sb.append("}");
082    
083                    return sb.toString();
084            }
085    
086            @Override
087            public TrashVersion toEntityModel() {
088                    TrashVersionImpl trashVersionImpl = new TrashVersionImpl();
089    
090                    trashVersionImpl.setVersionId(versionId);
091                    trashVersionImpl.setEntryId(entryId);
092                    trashVersionImpl.setClassNameId(classNameId);
093                    trashVersionImpl.setClassPK(classPK);
094    
095                    if (typeSettings == null) {
096                            trashVersionImpl.setTypeSettings(StringPool.BLANK);
097                    }
098                    else {
099                            trashVersionImpl.setTypeSettings(typeSettings);
100                    }
101    
102                    trashVersionImpl.setStatus(status);
103    
104                    trashVersionImpl.resetOriginalValues();
105    
106                    return trashVersionImpl;
107            }
108    
109            @Override
110            public void readExternal(ObjectInput objectInput) throws IOException {
111                    versionId = objectInput.readLong();
112                    entryId = objectInput.readLong();
113                    classNameId = objectInput.readLong();
114                    classPK = objectInput.readLong();
115                    typeSettings = objectInput.readUTF();
116                    status = objectInput.readInt();
117            }
118    
119            @Override
120            public void writeExternal(ObjectOutput objectOutput)
121                    throws IOException {
122                    objectOutput.writeLong(versionId);
123                    objectOutput.writeLong(entryId);
124                    objectOutput.writeLong(classNameId);
125                    objectOutput.writeLong(classPK);
126    
127                    if (typeSettings == null) {
128                            objectOutput.writeUTF(StringPool.BLANK);
129                    }
130                    else {
131                            objectOutput.writeUTF(typeSettings);
132                    }
133    
134                    objectOutput.writeInt(status);
135            }
136    
137            public long versionId;
138            public long entryId;
139            public long classNameId;
140            public long classPK;
141            public String typeSettings;
142            public int status;
143    }