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.UserTracker;
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 UserTracker in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see UserTracker
038     * @generated
039     */
040    @ProviderType
041    public class UserTrackerCacheModel implements CacheModel<UserTracker>,
042            Externalizable, MVCCModel {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof UserTrackerCacheModel)) {
050                            return false;
051                    }
052    
053                    UserTrackerCacheModel userTrackerCacheModel = (UserTrackerCacheModel)obj;
054    
055                    if ((userTrackerId == userTrackerCacheModel.userTrackerId) &&
056                                    (mvccVersion == userTrackerCacheModel.mvccVersion)) {
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hashCode = HashUtil.hash(0, userTrackerId);
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(19);
083    
084                    sb.append("{mvccVersion=");
085                    sb.append(mvccVersion);
086                    sb.append(", userTrackerId=");
087                    sb.append(userTrackerId);
088                    sb.append(", companyId=");
089                    sb.append(companyId);
090                    sb.append(", userId=");
091                    sb.append(userId);
092                    sb.append(", modifiedDate=");
093                    sb.append(modifiedDate);
094                    sb.append(", sessionId=");
095                    sb.append(sessionId);
096                    sb.append(", remoteAddr=");
097                    sb.append(remoteAddr);
098                    sb.append(", remoteHost=");
099                    sb.append(remoteHost);
100                    sb.append(", userAgent=");
101                    sb.append(userAgent);
102                    sb.append("}");
103    
104                    return sb.toString();
105            }
106    
107            @Override
108            public UserTracker toEntityModel() {
109                    UserTrackerImpl userTrackerImpl = new UserTrackerImpl();
110    
111                    userTrackerImpl.setMvccVersion(mvccVersion);
112                    userTrackerImpl.setUserTrackerId(userTrackerId);
113                    userTrackerImpl.setCompanyId(companyId);
114                    userTrackerImpl.setUserId(userId);
115    
116                    if (modifiedDate == Long.MIN_VALUE) {
117                            userTrackerImpl.setModifiedDate(null);
118                    }
119                    else {
120                            userTrackerImpl.setModifiedDate(new Date(modifiedDate));
121                    }
122    
123                    if (sessionId == null) {
124                            userTrackerImpl.setSessionId(StringPool.BLANK);
125                    }
126                    else {
127                            userTrackerImpl.setSessionId(sessionId);
128                    }
129    
130                    if (remoteAddr == null) {
131                            userTrackerImpl.setRemoteAddr(StringPool.BLANK);
132                    }
133                    else {
134                            userTrackerImpl.setRemoteAddr(remoteAddr);
135                    }
136    
137                    if (remoteHost == null) {
138                            userTrackerImpl.setRemoteHost(StringPool.BLANK);
139                    }
140                    else {
141                            userTrackerImpl.setRemoteHost(remoteHost);
142                    }
143    
144                    if (userAgent == null) {
145                            userTrackerImpl.setUserAgent(StringPool.BLANK);
146                    }
147                    else {
148                            userTrackerImpl.setUserAgent(userAgent);
149                    }
150    
151                    userTrackerImpl.resetOriginalValues();
152    
153                    return userTrackerImpl;
154            }
155    
156            @Override
157            public void readExternal(ObjectInput objectInput) throws IOException {
158                    mvccVersion = objectInput.readLong();
159                    userTrackerId = objectInput.readLong();
160                    companyId = objectInput.readLong();
161                    userId = objectInput.readLong();
162                    modifiedDate = objectInput.readLong();
163                    sessionId = objectInput.readUTF();
164                    remoteAddr = objectInput.readUTF();
165                    remoteHost = objectInput.readUTF();
166                    userAgent = objectInput.readUTF();
167            }
168    
169            @Override
170            public void writeExternal(ObjectOutput objectOutput)
171                    throws IOException {
172                    objectOutput.writeLong(mvccVersion);
173                    objectOutput.writeLong(userTrackerId);
174                    objectOutput.writeLong(companyId);
175                    objectOutput.writeLong(userId);
176                    objectOutput.writeLong(modifiedDate);
177    
178                    if (sessionId == null) {
179                            objectOutput.writeUTF(StringPool.BLANK);
180                    }
181                    else {
182                            objectOutput.writeUTF(sessionId);
183                    }
184    
185                    if (remoteAddr == null) {
186                            objectOutput.writeUTF(StringPool.BLANK);
187                    }
188                    else {
189                            objectOutput.writeUTF(remoteAddr);
190                    }
191    
192                    if (remoteHost == null) {
193                            objectOutput.writeUTF(StringPool.BLANK);
194                    }
195                    else {
196                            objectOutput.writeUTF(remoteHost);
197                    }
198    
199                    if (userAgent == null) {
200                            objectOutput.writeUTF(StringPool.BLANK);
201                    }
202                    else {
203                            objectOutput.writeUTF(userAgent);
204                    }
205            }
206    
207            public long mvccVersion;
208            public long userTrackerId;
209            public long companyId;
210            public long userId;
211            public long modifiedDate;
212            public String sessionId;
213            public String remoteAddr;
214            public String remoteHost;
215            public String userAgent;
216    }