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            public PasswordTracker toEntityModel() {
056                    PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
057    
058                    passwordTrackerImpl.setPasswordTrackerId(passwordTrackerId);
059                    passwordTrackerImpl.setUserId(userId);
060    
061                    if (createDate == Long.MIN_VALUE) {
062                            passwordTrackerImpl.setCreateDate(null);
063                    }
064                    else {
065                            passwordTrackerImpl.setCreateDate(new Date(createDate));
066                    }
067    
068                    if (password == null) {
069                            passwordTrackerImpl.setPassword(StringPool.BLANK);
070                    }
071                    else {
072                            passwordTrackerImpl.setPassword(password);
073                    }
074    
075                    passwordTrackerImpl.resetOriginalValues();
076    
077                    return passwordTrackerImpl;
078            }
079    
080            public void readExternal(ObjectInput objectInput) throws IOException {
081                    passwordTrackerId = objectInput.readLong();
082                    userId = objectInput.readLong();
083                    createDate = objectInput.readLong();
084                    password = objectInput.readUTF();
085            }
086    
087            public void writeExternal(ObjectOutput objectOutput)
088                    throws IOException {
089                    objectOutput.writeLong(passwordTrackerId);
090                    objectOutput.writeLong(userId);
091                    objectOutput.writeLong(createDate);
092    
093                    if (password == null) {
094                            objectOutput.writeUTF(StringPool.BLANK);
095                    }
096                    else {
097                            objectOutput.writeUTF(password);
098                    }
099            }
100    
101            public long passwordTrackerId;
102            public long userId;
103            public long createDate;
104            public String password;
105    }