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.documentlibrary.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.documentlibrary.model.DLContent;
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 DLContent in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see DLContent
036     * @generated
037     */
038    @ProviderType
039    public class DLContentCacheModel implements CacheModel<DLContent>,
040            Externalizable {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof DLContentCacheModel)) {
048                            return false;
049                    }
050    
051                    DLContentCacheModel dlContentCacheModel = (DLContentCacheModel)obj;
052    
053                    if (contentId == dlContentCacheModel.contentId) {
054                            return true;
055                    }
056    
057                    return false;
058            }
059    
060            @Override
061            public int hashCode() {
062                    return HashUtil.hash(0, contentId);
063            }
064    
065            @Override
066            public String toString() {
067                    StringBundler sb = new StringBundler(15);
068    
069                    sb.append("{contentId=");
070                    sb.append(contentId);
071                    sb.append(", groupId=");
072                    sb.append(groupId);
073                    sb.append(", companyId=");
074                    sb.append(companyId);
075                    sb.append(", repositoryId=");
076                    sb.append(repositoryId);
077                    sb.append(", path=");
078                    sb.append(path);
079                    sb.append(", version=");
080                    sb.append(version);
081                    sb.append(", size=");
082                    sb.append(size);
083                    sb.append("}");
084    
085                    return sb.toString();
086            }
087    
088            @Override
089            public DLContent toEntityModel() {
090                    DLContentImpl dlContentImpl = new DLContentImpl();
091    
092                    dlContentImpl.setContentId(contentId);
093                    dlContentImpl.setGroupId(groupId);
094                    dlContentImpl.setCompanyId(companyId);
095                    dlContentImpl.setRepositoryId(repositoryId);
096    
097                    if (path == null) {
098                            dlContentImpl.setPath(StringPool.BLANK);
099                    }
100                    else {
101                            dlContentImpl.setPath(path);
102                    }
103    
104                    if (version == null) {
105                            dlContentImpl.setVersion(StringPool.BLANK);
106                    }
107                    else {
108                            dlContentImpl.setVersion(version);
109                    }
110    
111                    dlContentImpl.setSize(size);
112    
113                    dlContentImpl.resetOriginalValues();
114    
115                    return dlContentImpl;
116            }
117    
118            @Override
119            public void readExternal(ObjectInput objectInput) throws IOException {
120                    contentId = objectInput.readLong();
121                    groupId = objectInput.readLong();
122                    companyId = objectInput.readLong();
123                    repositoryId = objectInput.readLong();
124                    path = objectInput.readUTF();
125                    version = objectInput.readUTF();
126                    size = objectInput.readLong();
127            }
128    
129            @Override
130            public void writeExternal(ObjectOutput objectOutput)
131                    throws IOException {
132                    objectOutput.writeLong(contentId);
133                    objectOutput.writeLong(groupId);
134                    objectOutput.writeLong(companyId);
135                    objectOutput.writeLong(repositoryId);
136    
137                    if (path == null) {
138                            objectOutput.writeUTF(StringPool.BLANK);
139                    }
140                    else {
141                            objectOutput.writeUTF(path);
142                    }
143    
144                    if (version == null) {
145                            objectOutput.writeUTF(StringPool.BLANK);
146                    }
147                    else {
148                            objectOutput.writeUTF(version);
149                    }
150    
151                    objectOutput.writeLong(size);
152            }
153    
154            public long contentId;
155            public long groupId;
156            public long companyId;
157            public long repositoryId;
158            public String path;
159            public String version;
160            public long size;
161    }