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.softwarecatalog.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.softwarecatalog.model.SCProductVersion;
025    
026    import java.io.Externalizable;
027    import java.io.IOException;
028    import java.io.ObjectInput;
029    import java.io.ObjectOutput;
030    
031    import java.util.Date;
032    
033    /**
034     * The cache model class for representing SCProductVersion in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see SCProductVersion
038     * @generated
039     */
040    @ProviderType
041    public class SCProductVersionCacheModel implements CacheModel<SCProductVersion>,
042            Externalizable {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof SCProductVersionCacheModel)) {
050                            return false;
051                    }
052    
053                    SCProductVersionCacheModel scProductVersionCacheModel = (SCProductVersionCacheModel)obj;
054    
055                    if (productVersionId == scProductVersionCacheModel.productVersionId) {
056                            return true;
057                    }
058    
059                    return false;
060            }
061    
062            @Override
063            public int hashCode() {
064                    return HashUtil.hash(0, productVersionId);
065            }
066    
067            @Override
068            public String toString() {
069                    StringBundler sb = new StringBundler(25);
070    
071                    sb.append("{productVersionId=");
072                    sb.append(productVersionId);
073                    sb.append(", companyId=");
074                    sb.append(companyId);
075                    sb.append(", userId=");
076                    sb.append(userId);
077                    sb.append(", userName=");
078                    sb.append(userName);
079                    sb.append(", createDate=");
080                    sb.append(createDate);
081                    sb.append(", modifiedDate=");
082                    sb.append(modifiedDate);
083                    sb.append(", productEntryId=");
084                    sb.append(productEntryId);
085                    sb.append(", version=");
086                    sb.append(version);
087                    sb.append(", changeLog=");
088                    sb.append(changeLog);
089                    sb.append(", downloadPageURL=");
090                    sb.append(downloadPageURL);
091                    sb.append(", directDownloadURL=");
092                    sb.append(directDownloadURL);
093                    sb.append(", repoStoreArtifact=");
094                    sb.append(repoStoreArtifact);
095                    sb.append("}");
096    
097                    return sb.toString();
098            }
099    
100            @Override
101            public SCProductVersion toEntityModel() {
102                    SCProductVersionImpl scProductVersionImpl = new SCProductVersionImpl();
103    
104                    scProductVersionImpl.setProductVersionId(productVersionId);
105                    scProductVersionImpl.setCompanyId(companyId);
106                    scProductVersionImpl.setUserId(userId);
107    
108                    if (userName == null) {
109                            scProductVersionImpl.setUserName(StringPool.BLANK);
110                    }
111                    else {
112                            scProductVersionImpl.setUserName(userName);
113                    }
114    
115                    if (createDate == Long.MIN_VALUE) {
116                            scProductVersionImpl.setCreateDate(null);
117                    }
118                    else {
119                            scProductVersionImpl.setCreateDate(new Date(createDate));
120                    }
121    
122                    if (modifiedDate == Long.MIN_VALUE) {
123                            scProductVersionImpl.setModifiedDate(null);
124                    }
125                    else {
126                            scProductVersionImpl.setModifiedDate(new Date(modifiedDate));
127                    }
128    
129                    scProductVersionImpl.setProductEntryId(productEntryId);
130    
131                    if (version == null) {
132                            scProductVersionImpl.setVersion(StringPool.BLANK);
133                    }
134                    else {
135                            scProductVersionImpl.setVersion(version);
136                    }
137    
138                    if (changeLog == null) {
139                            scProductVersionImpl.setChangeLog(StringPool.BLANK);
140                    }
141                    else {
142                            scProductVersionImpl.setChangeLog(changeLog);
143                    }
144    
145                    if (downloadPageURL == null) {
146                            scProductVersionImpl.setDownloadPageURL(StringPool.BLANK);
147                    }
148                    else {
149                            scProductVersionImpl.setDownloadPageURL(downloadPageURL);
150                    }
151    
152                    if (directDownloadURL == null) {
153                            scProductVersionImpl.setDirectDownloadURL(StringPool.BLANK);
154                    }
155                    else {
156                            scProductVersionImpl.setDirectDownloadURL(directDownloadURL);
157                    }
158    
159                    scProductVersionImpl.setRepoStoreArtifact(repoStoreArtifact);
160    
161                    scProductVersionImpl.resetOriginalValues();
162    
163                    return scProductVersionImpl;
164            }
165    
166            @Override
167            public void readExternal(ObjectInput objectInput) throws IOException {
168                    productVersionId = objectInput.readLong();
169                    companyId = objectInput.readLong();
170                    userId = objectInput.readLong();
171                    userName = objectInput.readUTF();
172                    createDate = objectInput.readLong();
173                    modifiedDate = objectInput.readLong();
174                    productEntryId = objectInput.readLong();
175                    version = objectInput.readUTF();
176                    changeLog = objectInput.readUTF();
177                    downloadPageURL = objectInput.readUTF();
178                    directDownloadURL = objectInput.readUTF();
179                    repoStoreArtifact = objectInput.readBoolean();
180            }
181    
182            @Override
183            public void writeExternal(ObjectOutput objectOutput)
184                    throws IOException {
185                    objectOutput.writeLong(productVersionId);
186                    objectOutput.writeLong(companyId);
187                    objectOutput.writeLong(userId);
188    
189                    if (userName == null) {
190                            objectOutput.writeUTF(StringPool.BLANK);
191                    }
192                    else {
193                            objectOutput.writeUTF(userName);
194                    }
195    
196                    objectOutput.writeLong(createDate);
197                    objectOutput.writeLong(modifiedDate);
198                    objectOutput.writeLong(productEntryId);
199    
200                    if (version == null) {
201                            objectOutput.writeUTF(StringPool.BLANK);
202                    }
203                    else {
204                            objectOutput.writeUTF(version);
205                    }
206    
207                    if (changeLog == null) {
208                            objectOutput.writeUTF(StringPool.BLANK);
209                    }
210                    else {
211                            objectOutput.writeUTF(changeLog);
212                    }
213    
214                    if (downloadPageURL == null) {
215                            objectOutput.writeUTF(StringPool.BLANK);
216                    }
217                    else {
218                            objectOutput.writeUTF(downloadPageURL);
219                    }
220    
221                    if (directDownloadURL == null) {
222                            objectOutput.writeUTF(StringPool.BLANK);
223                    }
224                    else {
225                            objectOutput.writeUTF(directDownloadURL);
226                    }
227    
228                    objectOutput.writeBoolean(repoStoreArtifact);
229            }
230    
231            public long productVersionId;
232            public long companyId;
233            public long userId;
234            public String userName;
235            public long createDate;
236            public long modifiedDate;
237            public long productEntryId;
238            public String version;
239            public String changeLog;
240            public String downloadPageURL;
241            public String directDownloadURL;
242            public boolean repoStoreArtifact;
243    }