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(31);
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("}");
115    
116                    return sb.toString();
117            }
118    
119            @Override
120            public Repository toEntityModel() {
121                    RepositoryImpl repositoryImpl = new RepositoryImpl();
122    
123                    repositoryImpl.setMvccVersion(mvccVersion);
124    
125                    if (uuid == null) {
126                            repositoryImpl.setUuid(StringPool.BLANK);
127                    }
128                    else {
129                            repositoryImpl.setUuid(uuid);
130                    }
131    
132                    repositoryImpl.setRepositoryId(repositoryId);
133                    repositoryImpl.setGroupId(groupId);
134                    repositoryImpl.setCompanyId(companyId);
135                    repositoryImpl.setUserId(userId);
136    
137                    if (userName == null) {
138                            repositoryImpl.setUserName(StringPool.BLANK);
139                    }
140                    else {
141                            repositoryImpl.setUserName(userName);
142                    }
143    
144                    if (createDate == Long.MIN_VALUE) {
145                            repositoryImpl.setCreateDate(null);
146                    }
147                    else {
148                            repositoryImpl.setCreateDate(new Date(createDate));
149                    }
150    
151                    if (modifiedDate == Long.MIN_VALUE) {
152                            repositoryImpl.setModifiedDate(null);
153                    }
154                    else {
155                            repositoryImpl.setModifiedDate(new Date(modifiedDate));
156                    }
157    
158                    repositoryImpl.setClassNameId(classNameId);
159    
160                    if (name == null) {
161                            repositoryImpl.setName(StringPool.BLANK);
162                    }
163                    else {
164                            repositoryImpl.setName(name);
165                    }
166    
167                    if (description == null) {
168                            repositoryImpl.setDescription(StringPool.BLANK);
169                    }
170                    else {
171                            repositoryImpl.setDescription(description);
172                    }
173    
174                    if (portletId == null) {
175                            repositoryImpl.setPortletId(StringPool.BLANK);
176                    }
177                    else {
178                            repositoryImpl.setPortletId(portletId);
179                    }
180    
181                    if (typeSettings == null) {
182                            repositoryImpl.setTypeSettings(StringPool.BLANK);
183                    }
184                    else {
185                            repositoryImpl.setTypeSettings(typeSettings);
186                    }
187    
188                    repositoryImpl.setDlFolderId(dlFolderId);
189    
190                    repositoryImpl.resetOriginalValues();
191    
192                    return repositoryImpl;
193            }
194    
195            @Override
196            public void readExternal(ObjectInput objectInput) throws IOException {
197                    mvccVersion = objectInput.readLong();
198                    uuid = objectInput.readUTF();
199                    repositoryId = objectInput.readLong();
200                    groupId = objectInput.readLong();
201                    companyId = objectInput.readLong();
202                    userId = objectInput.readLong();
203                    userName = objectInput.readUTF();
204                    createDate = objectInput.readLong();
205                    modifiedDate = objectInput.readLong();
206                    classNameId = objectInput.readLong();
207                    name = objectInput.readUTF();
208                    description = objectInput.readUTF();
209                    portletId = objectInput.readUTF();
210                    typeSettings = objectInput.readUTF();
211                    dlFolderId = objectInput.readLong();
212            }
213    
214            @Override
215            public void writeExternal(ObjectOutput objectOutput)
216                    throws IOException {
217                    objectOutput.writeLong(mvccVersion);
218    
219                    if (uuid == null) {
220                            objectOutput.writeUTF(StringPool.BLANK);
221                    }
222                    else {
223                            objectOutput.writeUTF(uuid);
224                    }
225    
226                    objectOutput.writeLong(repositoryId);
227                    objectOutput.writeLong(groupId);
228                    objectOutput.writeLong(companyId);
229                    objectOutput.writeLong(userId);
230    
231                    if (userName == null) {
232                            objectOutput.writeUTF(StringPool.BLANK);
233                    }
234                    else {
235                            objectOutput.writeUTF(userName);
236                    }
237    
238                    objectOutput.writeLong(createDate);
239                    objectOutput.writeLong(modifiedDate);
240                    objectOutput.writeLong(classNameId);
241    
242                    if (name == null) {
243                            objectOutput.writeUTF(StringPool.BLANK);
244                    }
245                    else {
246                            objectOutput.writeUTF(name);
247                    }
248    
249                    if (description == null) {
250                            objectOutput.writeUTF(StringPool.BLANK);
251                    }
252                    else {
253                            objectOutput.writeUTF(description);
254                    }
255    
256                    if (portletId == null) {
257                            objectOutput.writeUTF(StringPool.BLANK);
258                    }
259                    else {
260                            objectOutput.writeUTF(portletId);
261                    }
262    
263                    if (typeSettings == null) {
264                            objectOutput.writeUTF(StringPool.BLANK);
265                    }
266                    else {
267                            objectOutput.writeUTF(typeSettings);
268                    }
269    
270                    objectOutput.writeLong(dlFolderId);
271            }
272    
273            public long mvccVersion;
274            public String uuid;
275            public long repositoryId;
276            public long groupId;
277            public long companyId;
278            public long userId;
279            public String userName;
280            public long createDate;
281            public long modifiedDate;
282            public long classNameId;
283            public String name;
284            public String description;
285            public String portletId;
286            public String typeSettings;
287            public long dlFolderId;
288    }