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.UserTracker;
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 UserTracker in entity cache.
034     *
035     * @author Brian Wing Shun Chan
036     * @see UserTracker
037     * @generated
038     */
039    @ProviderType
040    public class UserTrackerCacheModel implements CacheModel<UserTracker>,
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(19);
055    
056                    sb.append("{mvccVersion=");
057                    sb.append(mvccVersion);
058                    sb.append(", userTrackerId=");
059                    sb.append(userTrackerId);
060                    sb.append(", companyId=");
061                    sb.append(companyId);
062                    sb.append(", userId=");
063                    sb.append(userId);
064                    sb.append(", modifiedDate=");
065                    sb.append(modifiedDate);
066                    sb.append(", sessionId=");
067                    sb.append(sessionId);
068                    sb.append(", remoteAddr=");
069                    sb.append(remoteAddr);
070                    sb.append(", remoteHost=");
071                    sb.append(remoteHost);
072                    sb.append(", userAgent=");
073                    sb.append(userAgent);
074                    sb.append("}");
075    
076                    return sb.toString();
077            }
078    
079            @Override
080            public UserTracker toEntityModel() {
081                    UserTrackerImpl userTrackerImpl = new UserTrackerImpl();
082    
083                    userTrackerImpl.setMvccVersion(mvccVersion);
084                    userTrackerImpl.setUserTrackerId(userTrackerId);
085                    userTrackerImpl.setCompanyId(companyId);
086                    userTrackerImpl.setUserId(userId);
087    
088                    if (modifiedDate == Long.MIN_VALUE) {
089                            userTrackerImpl.setModifiedDate(null);
090                    }
091                    else {
092                            userTrackerImpl.setModifiedDate(new Date(modifiedDate));
093                    }
094    
095                    if (sessionId == null) {
096                            userTrackerImpl.setSessionId(StringPool.BLANK);
097                    }
098                    else {
099                            userTrackerImpl.setSessionId(sessionId);
100                    }
101    
102                    if (remoteAddr == null) {
103                            userTrackerImpl.setRemoteAddr(StringPool.BLANK);
104                    }
105                    else {
106                            userTrackerImpl.setRemoteAddr(remoteAddr);
107                    }
108    
109                    if (remoteHost == null) {
110                            userTrackerImpl.setRemoteHost(StringPool.BLANK);
111                    }
112                    else {
113                            userTrackerImpl.setRemoteHost(remoteHost);
114                    }
115    
116                    if (userAgent == null) {
117                            userTrackerImpl.setUserAgent(StringPool.BLANK);
118                    }
119                    else {
120                            userTrackerImpl.setUserAgent(userAgent);
121                    }
122    
123                    userTrackerImpl.resetOriginalValues();
124    
125                    return userTrackerImpl;
126            }
127    
128            @Override
129            public void readExternal(ObjectInput objectInput) throws IOException {
130                    mvccVersion = objectInput.readLong();
131                    userTrackerId = objectInput.readLong();
132                    companyId = objectInput.readLong();
133                    userId = objectInput.readLong();
134                    modifiedDate = objectInput.readLong();
135                    sessionId = objectInput.readUTF();
136                    remoteAddr = objectInput.readUTF();
137                    remoteHost = objectInput.readUTF();
138                    userAgent = objectInput.readUTF();
139            }
140    
141            @Override
142            public void writeExternal(ObjectOutput objectOutput)
143                    throws IOException {
144                    objectOutput.writeLong(mvccVersion);
145                    objectOutput.writeLong(userTrackerId);
146                    objectOutput.writeLong(companyId);
147                    objectOutput.writeLong(userId);
148                    objectOutput.writeLong(modifiedDate);
149    
150                    if (sessionId == null) {
151                            objectOutput.writeUTF(StringPool.BLANK);
152                    }
153                    else {
154                            objectOutput.writeUTF(sessionId);
155                    }
156    
157                    if (remoteAddr == null) {
158                            objectOutput.writeUTF(StringPool.BLANK);
159                    }
160                    else {
161                            objectOutput.writeUTF(remoteAddr);
162                    }
163    
164                    if (remoteHost == null) {
165                            objectOutput.writeUTF(StringPool.BLANK);
166                    }
167                    else {
168                            objectOutput.writeUTF(remoteHost);
169                    }
170    
171                    if (userAgent == null) {
172                            objectOutput.writeUTF(StringPool.BLANK);
173                    }
174                    else {
175                            objectOutput.writeUTF(userAgent);
176                    }
177            }
178    
179            public long mvccVersion;
180            public long userTrackerId;
181            public long companyId;
182            public long userId;
183            public long modifiedDate;
184            public String sessionId;
185            public String remoteAddr;
186            public String remoteHost;
187            public String userAgent;
188    }