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.PasswordTracker;
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 PasswordTracker in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see PasswordTracker
038     * @generated
039     */
040    @ProviderType
041    public class PasswordTrackerCacheModel implements CacheModel<PasswordTracker>,
042            Externalizable, MVCCModel {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof PasswordTrackerCacheModel)) {
050                            return false;
051                    }
052    
053                    PasswordTrackerCacheModel passwordTrackerCacheModel = (PasswordTrackerCacheModel)obj;
054    
055                    if ((passwordTrackerId == passwordTrackerCacheModel.passwordTrackerId) &&
056                                    (mvccVersion == passwordTrackerCacheModel.mvccVersion)) {
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hashCode = HashUtil.hash(0, passwordTrackerId);
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(13);
083    
084                    sb.append("{mvccVersion=");
085                    sb.append(mvccVersion);
086                    sb.append(", passwordTrackerId=");
087                    sb.append(passwordTrackerId);
088                    sb.append(", companyId=");
089                    sb.append(companyId);
090                    sb.append(", userId=");
091                    sb.append(userId);
092                    sb.append(", createDate=");
093                    sb.append(createDate);
094                    sb.append(", password=");
095                    sb.append(password);
096                    sb.append("}");
097    
098                    return sb.toString();
099            }
100    
101            @Override
102            public PasswordTracker toEntityModel() {
103                    PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
104    
105                    passwordTrackerImpl.setMvccVersion(mvccVersion);
106                    passwordTrackerImpl.setPasswordTrackerId(passwordTrackerId);
107                    passwordTrackerImpl.setCompanyId(companyId);
108                    passwordTrackerImpl.setUserId(userId);
109    
110                    if (createDate == Long.MIN_VALUE) {
111                            passwordTrackerImpl.setCreateDate(null);
112                    }
113                    else {
114                            passwordTrackerImpl.setCreateDate(new Date(createDate));
115                    }
116    
117                    if (password == null) {
118                            passwordTrackerImpl.setPassword(StringPool.BLANK);
119                    }
120                    else {
121                            passwordTrackerImpl.setPassword(password);
122                    }
123    
124                    passwordTrackerImpl.resetOriginalValues();
125    
126                    return passwordTrackerImpl;
127            }
128    
129            @Override
130            public void readExternal(ObjectInput objectInput) throws IOException {
131                    mvccVersion = objectInput.readLong();
132                    passwordTrackerId = objectInput.readLong();
133                    companyId = objectInput.readLong();
134                    userId = objectInput.readLong();
135                    createDate = objectInput.readLong();
136                    password = objectInput.readUTF();
137            }
138    
139            @Override
140            public void writeExternal(ObjectOutput objectOutput)
141                    throws IOException {
142                    objectOutput.writeLong(mvccVersion);
143                    objectOutput.writeLong(passwordTrackerId);
144                    objectOutput.writeLong(companyId);
145                    objectOutput.writeLong(userId);
146                    objectOutput.writeLong(createDate);
147    
148                    if (password == null) {
149                            objectOutput.writeUTF(StringPool.BLANK);
150                    }
151                    else {
152                            objectOutput.writeUTF(password);
153                    }
154            }
155    
156            public long mvccVersion;
157            public long passwordTrackerId;
158            public long companyId;
159            public long userId;
160            public long createDate;
161            public String password;
162    }