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.MVCCModel;
024    import com.liferay.portal.model.Repository;
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                    repositoryId = objectInput.readLong();
209                    groupId = objectInput.readLong();
210                    companyId = objectInput.readLong();
211                    userId = objectInput.readLong();
212                    userName = objectInput.readUTF();
213                    createDate = objectInput.readLong();
214                    modifiedDate = objectInput.readLong();
215                    classNameId = objectInput.readLong();
216                    name = objectInput.readUTF();
217                    description = objectInput.readUTF();
218                    portletId = objectInput.readUTF();
219                    typeSettings = objectInput.readUTF();
220                    dlFolderId = objectInput.readLong();
221                    lastPublishDate = objectInput.readLong();
222            }
223    
224            @Override
225            public void writeExternal(ObjectOutput objectOutput)
226                    throws IOException {
227                    objectOutput.writeLong(mvccVersion);
228    
229                    if (uuid == null) {
230                            objectOutput.writeUTF(StringPool.BLANK);
231                    }
232                    else {
233                            objectOutput.writeUTF(uuid);
234                    }
235    
236                    objectOutput.writeLong(repositoryId);
237                    objectOutput.writeLong(groupId);
238                    objectOutput.writeLong(companyId);
239                    objectOutput.writeLong(userId);
240    
241                    if (userName == null) {
242                            objectOutput.writeUTF(StringPool.BLANK);
243                    }
244                    else {
245                            objectOutput.writeUTF(userName);
246                    }
247    
248                    objectOutput.writeLong(createDate);
249                    objectOutput.writeLong(modifiedDate);
250                    objectOutput.writeLong(classNameId);
251    
252                    if (name == null) {
253                            objectOutput.writeUTF(StringPool.BLANK);
254                    }
255                    else {
256                            objectOutput.writeUTF(name);
257                    }
258    
259                    if (description == null) {
260                            objectOutput.writeUTF(StringPool.BLANK);
261                    }
262                    else {
263                            objectOutput.writeUTF(description);
264                    }
265    
266                    if (portletId == null) {
267                            objectOutput.writeUTF(StringPool.BLANK);
268                    }
269                    else {
270                            objectOutput.writeUTF(portletId);
271                    }
272    
273                    if (typeSettings == null) {
274                            objectOutput.writeUTF(StringPool.BLANK);
275                    }
276                    else {
277                            objectOutput.writeUTF(typeSettings);
278                    }
279    
280                    objectOutput.writeLong(dlFolderId);
281                    objectOutput.writeLong(lastPublishDate);
282            }
283    
284            public long mvccVersion;
285            public String uuid;
286            public long repositoryId;
287            public long groupId;
288            public long companyId;
289            public long userId;
290            public String userName;
291            public long createDate;
292            public long modifiedDate;
293            public long classNameId;
294            public String name;
295            public String description;
296            public String portletId;
297            public String typeSettings;
298            public long dlFolderId;
299            public long lastPublishDate;
300    }