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(11);
083    
084                    sb.append("{mvccVersion=");
085                    sb.append(mvccVersion);
086                    sb.append(", passwordTrackerId=");
087                    sb.append(passwordTrackerId);
088                    sb.append(", userId=");
089                    sb.append(userId);
090                    sb.append(", createDate=");
091                    sb.append(createDate);
092                    sb.append(", password=");
093                    sb.append(password);
094                    sb.append("}");
095    
096                    return sb.toString();
097            }
098    
099            @Override
100            public PasswordTracker toEntityModel() {
101                    PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
102    
103                    passwordTrackerImpl.setMvccVersion(mvccVersion);
104                    passwordTrackerImpl.setPasswordTrackerId(passwordTrackerId);
105                    passwordTrackerImpl.setUserId(userId);
106    
107                    if (createDate == Long.MIN_VALUE) {
108                            passwordTrackerImpl.setCreateDate(null);
109                    }
110                    else {
111                            passwordTrackerImpl.setCreateDate(new Date(createDate));
112                    }
113    
114                    if (password == null) {
115                            passwordTrackerImpl.setPassword(StringPool.BLANK);
116                    }
117                    else {
118                            passwordTrackerImpl.setPassword(password);
119                    }
120    
121                    passwordTrackerImpl.resetOriginalValues();
122    
123                    return passwordTrackerImpl;
124            }
125    
126            @Override
127            public void readExternal(ObjectInput objectInput) throws IOException {
128                    mvccVersion = objectInput.readLong();
129                    passwordTrackerId = objectInput.readLong();
130                    userId = objectInput.readLong();
131                    createDate = objectInput.readLong();
132                    password = objectInput.readUTF();
133            }
134    
135            @Override
136            public void writeExternal(ObjectOutput objectOutput)
137                    throws IOException {
138                    objectOutput.writeLong(mvccVersion);
139                    objectOutput.writeLong(passwordTrackerId);
140                    objectOutput.writeLong(userId);
141                    objectOutput.writeLong(createDate);
142    
143                    if (password == null) {
144                            objectOutput.writeUTF(StringPool.BLANK);
145                    }
146                    else {
147                            objectOutput.writeUTF(password);
148                    }
149            }
150    
151            public long mvccVersion;
152            public long passwordTrackerId;
153            public long userId;
154            public long createDate;
155            public String password;
156    }