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.PasswordPolicy;
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 PasswordPolicy in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see PasswordPolicy
038     * @generated
039     */
040    @ProviderType
041    public class PasswordPolicyCacheModel implements CacheModel<PasswordPolicy>,
042            Externalizable, MVCCModel {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof PasswordPolicyCacheModel)) {
050                            return false;
051                    }
052    
053                    PasswordPolicyCacheModel passwordPolicyCacheModel = (PasswordPolicyCacheModel)obj;
054    
055                    if ((passwordPolicyId == passwordPolicyCacheModel.passwordPolicyId) &&
056                                    (mvccVersion == passwordPolicyCacheModel.mvccVersion)) {
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hashCode = HashUtil.hash(0, passwordPolicyId);
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(71);
083    
084                    sb.append("{mvccVersion=");
085                    sb.append(mvccVersion);
086                    sb.append(", uuid=");
087                    sb.append(uuid);
088                    sb.append(", passwordPolicyId=");
089                    sb.append(passwordPolicyId);
090                    sb.append(", companyId=");
091                    sb.append(companyId);
092                    sb.append(", userId=");
093                    sb.append(userId);
094                    sb.append(", userName=");
095                    sb.append(userName);
096                    sb.append(", createDate=");
097                    sb.append(createDate);
098                    sb.append(", modifiedDate=");
099                    sb.append(modifiedDate);
100                    sb.append(", defaultPolicy=");
101                    sb.append(defaultPolicy);
102                    sb.append(", name=");
103                    sb.append(name);
104                    sb.append(", description=");
105                    sb.append(description);
106                    sb.append(", changeable=");
107                    sb.append(changeable);
108                    sb.append(", changeRequired=");
109                    sb.append(changeRequired);
110                    sb.append(", minAge=");
111                    sb.append(minAge);
112                    sb.append(", checkSyntax=");
113                    sb.append(checkSyntax);
114                    sb.append(", allowDictionaryWords=");
115                    sb.append(allowDictionaryWords);
116                    sb.append(", minAlphanumeric=");
117                    sb.append(minAlphanumeric);
118                    sb.append(", minLength=");
119                    sb.append(minLength);
120                    sb.append(", minLowerCase=");
121                    sb.append(minLowerCase);
122                    sb.append(", minNumbers=");
123                    sb.append(minNumbers);
124                    sb.append(", minSymbols=");
125                    sb.append(minSymbols);
126                    sb.append(", minUpperCase=");
127                    sb.append(minUpperCase);
128                    sb.append(", regex=");
129                    sb.append(regex);
130                    sb.append(", history=");
131                    sb.append(history);
132                    sb.append(", historyCount=");
133                    sb.append(historyCount);
134                    sb.append(", expireable=");
135                    sb.append(expireable);
136                    sb.append(", maxAge=");
137                    sb.append(maxAge);
138                    sb.append(", warningTime=");
139                    sb.append(warningTime);
140                    sb.append(", graceLimit=");
141                    sb.append(graceLimit);
142                    sb.append(", lockout=");
143                    sb.append(lockout);
144                    sb.append(", maxFailure=");
145                    sb.append(maxFailure);
146                    sb.append(", lockoutDuration=");
147                    sb.append(lockoutDuration);
148                    sb.append(", requireUnlock=");
149                    sb.append(requireUnlock);
150                    sb.append(", resetFailureCount=");
151                    sb.append(resetFailureCount);
152                    sb.append(", resetTicketMaxAge=");
153                    sb.append(resetTicketMaxAge);
154                    sb.append("}");
155    
156                    return sb.toString();
157            }
158    
159            @Override
160            public PasswordPolicy toEntityModel() {
161                    PasswordPolicyImpl passwordPolicyImpl = new PasswordPolicyImpl();
162    
163                    passwordPolicyImpl.setMvccVersion(mvccVersion);
164    
165                    if (uuid == null) {
166                            passwordPolicyImpl.setUuid(StringPool.BLANK);
167                    }
168                    else {
169                            passwordPolicyImpl.setUuid(uuid);
170                    }
171    
172                    passwordPolicyImpl.setPasswordPolicyId(passwordPolicyId);
173                    passwordPolicyImpl.setCompanyId(companyId);
174                    passwordPolicyImpl.setUserId(userId);
175    
176                    if (userName == null) {
177                            passwordPolicyImpl.setUserName(StringPool.BLANK);
178                    }
179                    else {
180                            passwordPolicyImpl.setUserName(userName);
181                    }
182    
183                    if (createDate == Long.MIN_VALUE) {
184                            passwordPolicyImpl.setCreateDate(null);
185                    }
186                    else {
187                            passwordPolicyImpl.setCreateDate(new Date(createDate));
188                    }
189    
190                    if (modifiedDate == Long.MIN_VALUE) {
191                            passwordPolicyImpl.setModifiedDate(null);
192                    }
193                    else {
194                            passwordPolicyImpl.setModifiedDate(new Date(modifiedDate));
195                    }
196    
197                    passwordPolicyImpl.setDefaultPolicy(defaultPolicy);
198    
199                    if (name == null) {
200                            passwordPolicyImpl.setName(StringPool.BLANK);
201                    }
202                    else {
203                            passwordPolicyImpl.setName(name);
204                    }
205    
206                    if (description == null) {
207                            passwordPolicyImpl.setDescription(StringPool.BLANK);
208                    }
209                    else {
210                            passwordPolicyImpl.setDescription(description);
211                    }
212    
213                    passwordPolicyImpl.setChangeable(changeable);
214                    passwordPolicyImpl.setChangeRequired(changeRequired);
215                    passwordPolicyImpl.setMinAge(minAge);
216                    passwordPolicyImpl.setCheckSyntax(checkSyntax);
217                    passwordPolicyImpl.setAllowDictionaryWords(allowDictionaryWords);
218                    passwordPolicyImpl.setMinAlphanumeric(minAlphanumeric);
219                    passwordPolicyImpl.setMinLength(minLength);
220                    passwordPolicyImpl.setMinLowerCase(minLowerCase);
221                    passwordPolicyImpl.setMinNumbers(minNumbers);
222                    passwordPolicyImpl.setMinSymbols(minSymbols);
223                    passwordPolicyImpl.setMinUpperCase(minUpperCase);
224    
225                    if (regex == null) {
226                            passwordPolicyImpl.setRegex(StringPool.BLANK);
227                    }
228                    else {
229                            passwordPolicyImpl.setRegex(regex);
230                    }
231    
232                    passwordPolicyImpl.setHistory(history);
233                    passwordPolicyImpl.setHistoryCount(historyCount);
234                    passwordPolicyImpl.setExpireable(expireable);
235                    passwordPolicyImpl.setMaxAge(maxAge);
236                    passwordPolicyImpl.setWarningTime(warningTime);
237                    passwordPolicyImpl.setGraceLimit(graceLimit);
238                    passwordPolicyImpl.setLockout(lockout);
239                    passwordPolicyImpl.setMaxFailure(maxFailure);
240                    passwordPolicyImpl.setLockoutDuration(lockoutDuration);
241                    passwordPolicyImpl.setRequireUnlock(requireUnlock);
242                    passwordPolicyImpl.setResetFailureCount(resetFailureCount);
243                    passwordPolicyImpl.setResetTicketMaxAge(resetTicketMaxAge);
244    
245                    passwordPolicyImpl.resetOriginalValues();
246    
247                    return passwordPolicyImpl;
248            }
249    
250            @Override
251            public void readExternal(ObjectInput objectInput) throws IOException {
252                    mvccVersion = objectInput.readLong();
253                    uuid = objectInput.readUTF();
254    
255                    passwordPolicyId = objectInput.readLong();
256    
257                    companyId = objectInput.readLong();
258    
259                    userId = objectInput.readLong();
260                    userName = objectInput.readUTF();
261                    createDate = objectInput.readLong();
262                    modifiedDate = objectInput.readLong();
263    
264                    defaultPolicy = objectInput.readBoolean();
265                    name = objectInput.readUTF();
266                    description = objectInput.readUTF();
267    
268                    changeable = objectInput.readBoolean();
269    
270                    changeRequired = objectInput.readBoolean();
271    
272                    minAge = objectInput.readLong();
273    
274                    checkSyntax = objectInput.readBoolean();
275    
276                    allowDictionaryWords = objectInput.readBoolean();
277    
278                    minAlphanumeric = objectInput.readInt();
279    
280                    minLength = objectInput.readInt();
281    
282                    minLowerCase = objectInput.readInt();
283    
284                    minNumbers = objectInput.readInt();
285    
286                    minSymbols = objectInput.readInt();
287    
288                    minUpperCase = objectInput.readInt();
289                    regex = objectInput.readUTF();
290    
291                    history = objectInput.readBoolean();
292    
293                    historyCount = objectInput.readInt();
294    
295                    expireable = objectInput.readBoolean();
296    
297                    maxAge = objectInput.readLong();
298    
299                    warningTime = objectInput.readLong();
300    
301                    graceLimit = objectInput.readInt();
302    
303                    lockout = objectInput.readBoolean();
304    
305                    maxFailure = objectInput.readInt();
306    
307                    lockoutDuration = objectInput.readLong();
308    
309                    requireUnlock = objectInput.readBoolean();
310    
311                    resetFailureCount = objectInput.readLong();
312    
313                    resetTicketMaxAge = objectInput.readLong();
314            }
315    
316            @Override
317            public void writeExternal(ObjectOutput objectOutput)
318                    throws IOException {
319                    objectOutput.writeLong(mvccVersion);
320    
321                    if (uuid == null) {
322                            objectOutput.writeUTF(StringPool.BLANK);
323                    }
324                    else {
325                            objectOutput.writeUTF(uuid);
326                    }
327    
328                    objectOutput.writeLong(passwordPolicyId);
329    
330                    objectOutput.writeLong(companyId);
331    
332                    objectOutput.writeLong(userId);
333    
334                    if (userName == null) {
335                            objectOutput.writeUTF(StringPool.BLANK);
336                    }
337                    else {
338                            objectOutput.writeUTF(userName);
339                    }
340    
341                    objectOutput.writeLong(createDate);
342                    objectOutput.writeLong(modifiedDate);
343    
344                    objectOutput.writeBoolean(defaultPolicy);
345    
346                    if (name == null) {
347                            objectOutput.writeUTF(StringPool.BLANK);
348                    }
349                    else {
350                            objectOutput.writeUTF(name);
351                    }
352    
353                    if (description == null) {
354                            objectOutput.writeUTF(StringPool.BLANK);
355                    }
356                    else {
357                            objectOutput.writeUTF(description);
358                    }
359    
360                    objectOutput.writeBoolean(changeable);
361    
362                    objectOutput.writeBoolean(changeRequired);
363    
364                    objectOutput.writeLong(minAge);
365    
366                    objectOutput.writeBoolean(checkSyntax);
367    
368                    objectOutput.writeBoolean(allowDictionaryWords);
369    
370                    objectOutput.writeInt(minAlphanumeric);
371    
372                    objectOutput.writeInt(minLength);
373    
374                    objectOutput.writeInt(minLowerCase);
375    
376                    objectOutput.writeInt(minNumbers);
377    
378                    objectOutput.writeInt(minSymbols);
379    
380                    objectOutput.writeInt(minUpperCase);
381    
382                    if (regex == null) {
383                            objectOutput.writeUTF(StringPool.BLANK);
384                    }
385                    else {
386                            objectOutput.writeUTF(regex);
387                    }
388    
389                    objectOutput.writeBoolean(history);
390    
391                    objectOutput.writeInt(historyCount);
392    
393                    objectOutput.writeBoolean(expireable);
394    
395                    objectOutput.writeLong(maxAge);
396    
397                    objectOutput.writeLong(warningTime);
398    
399                    objectOutput.writeInt(graceLimit);
400    
401                    objectOutput.writeBoolean(lockout);
402    
403                    objectOutput.writeInt(maxFailure);
404    
405                    objectOutput.writeLong(lockoutDuration);
406    
407                    objectOutput.writeBoolean(requireUnlock);
408    
409                    objectOutput.writeLong(resetFailureCount);
410    
411                    objectOutput.writeLong(resetTicketMaxAge);
412            }
413    
414            public long mvccVersion;
415            public String uuid;
416            public long passwordPolicyId;
417            public long companyId;
418            public long userId;
419            public String userName;
420            public long createDate;
421            public long modifiedDate;
422            public boolean defaultPolicy;
423            public String name;
424            public String description;
425            public boolean changeable;
426            public boolean changeRequired;
427            public long minAge;
428            public boolean checkSyntax;
429            public boolean allowDictionaryWords;
430            public int minAlphanumeric;
431            public int minLength;
432            public int minLowerCase;
433            public int minNumbers;
434            public int minSymbols;
435            public int minUpperCase;
436            public String regex;
437            public boolean history;
438            public int historyCount;
439            public boolean expireable;
440            public long maxAge;
441            public long warningTime;
442            public int graceLimit;
443            public boolean lockout;
444            public int maxFailure;
445            public long lockoutDuration;
446            public boolean requireUnlock;
447            public long resetFailureCount;
448            public long resetTicketMaxAge;
449    }