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