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.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.CacheModel;
022    import com.liferay.portal.model.MVCCModel;
023    import com.liferay.portal.model.PasswordTracker;
024    
025    import java.io.Externalizable;
026    import java.io.IOException;
027    import java.io.ObjectInput;
028    import java.io.ObjectOutput;
029    
030    import java.util.Date;
031    
032    /**
033     * The cache model class for representing PasswordTracker in entity cache.
034     *
035     * @author Brian Wing Shun Chan
036     * @see PasswordTracker
037     * @generated
038     */
039    @ProviderType
040    public class PasswordTrackerCacheModel implements CacheModel<PasswordTracker>,
041            Externalizable, MVCCModel {
042            @Override
043            public long getMvccVersion() {
044                    return mvccVersion;
045            }
046    
047            @Override
048            public void setMvccVersion(long mvccVersion) {
049                    this.mvccVersion = mvccVersion;
050            }
051    
052            @Override
053            public String toString() {
054                    StringBundler sb = new StringBundler(11);
055    
056                    sb.append("{mvccVersion=");
057                    sb.append(mvccVersion);
058                    sb.append(", passwordTrackerId=");
059                    sb.append(passwordTrackerId);
060                    sb.append(", userId=");
061                    sb.append(userId);
062                    sb.append(", createDate=");
063                    sb.append(createDate);
064                    sb.append(", password=");
065                    sb.append(password);
066                    sb.append("}");
067    
068                    return sb.toString();
069            }
070    
071            @Override
072            public PasswordTracker toEntityModel() {
073                    PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
074    
075                    passwordTrackerImpl.setMvccVersion(mvccVersion);
076                    passwordTrackerImpl.setPasswordTrackerId(passwordTrackerId);
077                    passwordTrackerImpl.setUserId(userId);
078    
079                    if (createDate == Long.MIN_VALUE) {
080                            passwordTrackerImpl.setCreateDate(null);
081                    }
082                    else {
083                            passwordTrackerImpl.setCreateDate(new Date(createDate));
084                    }
085    
086                    if (password == null) {
087                            passwordTrackerImpl.setPassword(StringPool.BLANK);
088                    }
089                    else {
090                            passwordTrackerImpl.setPassword(password);
091                    }
092    
093                    passwordTrackerImpl.resetOriginalValues();
094    
095                    return passwordTrackerImpl;
096            }
097    
098            @Override
099            public void readExternal(ObjectInput objectInput) throws IOException {
100                    mvccVersion = objectInput.readLong();
101                    passwordTrackerId = objectInput.readLong();
102                    userId = objectInput.readLong();
103                    createDate = objectInput.readLong();
104                    password = objectInput.readUTF();
105            }
106    
107            @Override
108            public void writeExternal(ObjectOutput objectOutput)
109                    throws IOException {
110                    objectOutput.writeLong(mvccVersion);
111                    objectOutput.writeLong(passwordTrackerId);
112                    objectOutput.writeLong(userId);
113                    objectOutput.writeLong(createDate);
114    
115                    if (password == null) {
116                            objectOutput.writeUTF(StringPool.BLANK);
117                    }
118                    else {
119                            objectOutput.writeUTF(password);
120                    }
121            }
122    
123            public long mvccVersion;
124            public long passwordTrackerId;
125            public long userId;
126            public long createDate;
127            public String password;
128    }