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.model.CacheModel;
020    import com.liferay.portal.kernel.model.MVCCModel;
021    import com.liferay.portal.kernel.model.Repository;
022    import com.liferay.portal.kernel.util.HashUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
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 Repository in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see Repository
038     * @generated
039     */
040    @ProviderType
041    public class RepositoryCacheModel implements CacheModel<Repository>,
042            Externalizable, MVCCModel {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof RepositoryCacheModel)) {
050                            return false;
051                    }
052    
053                    RepositoryCacheModel repositoryCacheModel = (RepositoryCacheModel)obj;
054    
055                    if ((repositoryId == repositoryCacheModel.repositoryId) &&
056                                    (mvccVersion == repositoryCacheModel.mvccVersion)) {
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hashCode = HashUtil.hash(0, repositoryId);
066    
067                    return HashUtil.hash(hashCode, mvccVersion);
068            }
069    
070            @Override
071            public long getMvccVersion() {
072                    return mvccVersion;
073            }
074    
075            @Override
076            public void setMvccVersion(long mvccVersion) {
077                    this.mvccVersion = mvccVersion;
078            }
079    
080            @Override
081            public String toString() {
082                    StringBundler sb = new StringBundler(33);
083    
084                    sb.append("{mvccVersion=");
085                    sb.append(mvccVersion);
086                    sb.append(", uuid=");
087                    sb.append(uuid);
088                    sb.append(", repositoryId=");
089                    sb.append(repositoryId);
090                    sb.append(", groupId=");
091                    sb.append(groupId);
092                    sb.append(", companyId=");
093                    sb.append(companyId);
094                    sb.append(", userId=");
095                    sb.append(userId);
096                    sb.append(", userName=");
097                    sb.append(userName);
098                    sb.append(", createDate=");
099                    sb.append(createDate);
100                    sb.append(", modifiedDate=");
101                    sb.append(modifiedDate);
102                    sb.append(", classNameId=");
103                    sb.append(classNameId);
104                    sb.append(", name=");
105                    sb.append(name);
106                    sb.append(", description=");
107                    sb.append(description);
108                    sb.append(", portletId=");
109                    sb.append(portletId);
110                    sb.append(", typeSettings=");
111                    sb.append(typeSettings);
112                    sb.append(", dlFolderId=");
113                    sb.append(dlFolderId);
114                    sb.append(", lastPublishDate=");
115                    sb.append(lastPublishDate);
116                    sb.append("}");
117    
118                    return sb.toString();
119            }
120    
121            @Override
122            public Repository toEntityModel() {
123                    RepositoryImpl repositoryImpl = new RepositoryImpl();
124    
125                    repositoryImpl.setMvccVersion(mvccVersion);
126    
127                    if (uuid == null) {
128                            repositoryImpl.setUuid(StringPool.BLANK);
129                    }
130                    else {
131                            repositoryImpl.setUuid(uuid);
132                    }
133    
134                    repositoryImpl.setRepositoryId(repositoryId);
135                    repositoryImpl.setGroupId(groupId);
136                    repositoryImpl.setCompanyId(companyId);
137                    repositoryImpl.setUserId(userId);
138    
139                    if (userName == null) {
140                            repositoryImpl.setUserName(StringPool.BLANK);
141                    }
142                    else {
143                            repositoryImpl.setUserName(userName);
144                    }
145    
146                    if (createDate == Long.MIN_VALUE) {
147                            repositoryImpl.setCreateDate(null);
148                    }
149                    else {
150                            repositoryImpl.setCreateDate(new Date(createDate));
151                    }
152    
153                    if (modifiedDate == Long.MIN_VALUE) {
154                            repositoryImpl.setModifiedDate(null);
155                    }
156                    else {
157                            repositoryImpl.setModifiedDate(new Date(modifiedDate));
158                    }
159    
160                    repositoryImpl.setClassNameId(classNameId);
161    
162                    if (name == null) {
163                            repositoryImpl.setName(StringPool.BLANK);
164                    }
165                    else {
166                            repositoryImpl.setName(name);
167                    }
168    
169                    if (description == null) {
170                            repositoryImpl.setDescription(StringPool.BLANK);
171                    }
172                    else {
173                            repositoryImpl.setDescription(description);
174                    }
175    
176                    if (portletId == null) {
177                            repositoryImpl.setPortletId(StringPool.BLANK);
178                    }
179                    else {
180                            repositoryImpl.setPortletId(portletId);
181                    }
182    
183                    if (typeSettings == null) {
184                            repositoryImpl.setTypeSettings(StringPool.BLANK);
185                    }
186                    else {
187                            repositoryImpl.setTypeSettings(typeSettings);
188                    }
189    
190                    repositoryImpl.setDlFolderId(dlFolderId);
191    
192                    if (lastPublishDate == Long.MIN_VALUE) {
193                            repositoryImpl.setLastPublishDate(null);
194                    }
195                    else {
196                            repositoryImpl.setLastPublishDate(new Date(lastPublishDate));
197                    }
198    
199                    repositoryImpl.resetOriginalValues();
200    
201                    return repositoryImpl;
202            }
203    
204            @Override
205            public void readExternal(ObjectInput objectInput) throws IOException {
206                    mvccVersion = objectInput.readLong();
207                    uuid = objectInput.readUTF();
208    
209                    repositoryId = objectInput.readLong();
210    
211                    groupId = objectInput.readLong();
212    
213                    companyId = objectInput.readLong();
214    
215                    userId = objectInput.readLong();
216                    userName = objectInput.readUTF();
217                    createDate = objectInput.readLong();
218                    modifiedDate = objectInput.readLong();
219    
220                    classNameId = objectInput.readLong();
221                    name = objectInput.readUTF();
222                    description = objectInput.readUTF();
223                    portletId = objectInput.readUTF();
224                    typeSettings = objectInput.readUTF();
225    
226                    dlFolderId = objectInput.readLong();
227                    lastPublishDate = objectInput.readLong();
228            }
229    
230            @Override
231            public void writeExternal(ObjectOutput objectOutput)
232                    throws IOException {
233                    objectOutput.writeLong(mvccVersion);
234    
235                    if (uuid == null) {
236                            objectOutput.writeUTF(StringPool.BLANK);
237                    }
238                    else {
239                            objectOutput.writeUTF(uuid);
240                    }
241    
242                    objectOutput.writeLong(repositoryId);
243    
244                    objectOutput.writeLong(groupId);
245    
246                    objectOutput.writeLong(companyId);
247    
248                    objectOutput.writeLong(userId);
249    
250                    if (userName == null) {
251                            objectOutput.writeUTF(StringPool.BLANK);
252                    }
253                    else {
254                            objectOutput.writeUTF(userName);
255                    }
256    
257                    objectOutput.writeLong(createDate);
258                    objectOutput.writeLong(modifiedDate);
259    
260                    objectOutput.writeLong(classNameId);
261    
262                    if (name == null) {
263                            objectOutput.writeUTF(StringPool.BLANK);
264                    }
265                    else {
266                            objectOutput.writeUTF(name);
267                    }
268    
269                    if (description == null) {
270                            objectOutput.writeUTF(StringPool.BLANK);
271                    }
272                    else {
273                            objectOutput.writeUTF(description);
274                    }
275    
276                    if (portletId == null) {
277                            objectOutput.writeUTF(StringPool.BLANK);
278                    }
279                    else {
280                            objectOutput.writeUTF(portletId);
281                    }
282    
283                    if (typeSettings == null) {
284                            objectOutput.writeUTF(StringPool.BLANK);
285                    }
286                    else {
287                            objectOutput.writeUTF(typeSettings);
288                    }
289    
290                    objectOutput.writeLong(dlFolderId);
291                    objectOutput.writeLong(lastPublishDate);
292            }
293    
294            public long mvccVersion;
295            public String uuid;
296            public long repositoryId;
297            public long groupId;
298            public long companyId;
299            public long userId;
300            public String userName;
301            public long createDate;
302            public long modifiedDate;
303            public long classNameId;
304            public String name;
305            public String description;
306            public String portletId;
307            public String typeSettings;
308            public long dlFolderId;
309            public long lastPublishDate;
310    }