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.SystemEvent;
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 SystemEvent in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see SystemEvent
038     * @generated
039     */
040    @ProviderType
041    public class SystemEventCacheModel implements CacheModel<SystemEvent>,
042            Externalizable, MVCCModel {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof SystemEventCacheModel)) {
050                            return false;
051                    }
052    
053                    SystemEventCacheModel systemEventCacheModel = (SystemEventCacheModel)obj;
054    
055                    if ((systemEventId == systemEventCacheModel.systemEventId) &&
056                                    (mvccVersion == systemEventCacheModel.mvccVersion)) {
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hashCode = HashUtil.hash(0, systemEventId);
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(31);
083    
084                    sb.append("{mvccVersion=");
085                    sb.append(mvccVersion);
086                    sb.append(", systemEventId=");
087                    sb.append(systemEventId);
088                    sb.append(", groupId=");
089                    sb.append(groupId);
090                    sb.append(", companyId=");
091                    sb.append(companyId);
092                    sb.append(", userId=");
093                    sb.append(userId);
094                    sb.append(", userName=");
095                    sb.append(userName);
096                    sb.append(", createDate=");
097                    sb.append(createDate);
098                    sb.append(", classNameId=");
099                    sb.append(classNameId);
100                    sb.append(", classPK=");
101                    sb.append(classPK);
102                    sb.append(", classUuid=");
103                    sb.append(classUuid);
104                    sb.append(", referrerClassNameId=");
105                    sb.append(referrerClassNameId);
106                    sb.append(", parentSystemEventId=");
107                    sb.append(parentSystemEventId);
108                    sb.append(", systemEventSetKey=");
109                    sb.append(systemEventSetKey);
110                    sb.append(", type=");
111                    sb.append(type);
112                    sb.append(", extraData=");
113                    sb.append(extraData);
114                    sb.append("}");
115    
116                    return sb.toString();
117            }
118    
119            @Override
120            public SystemEvent toEntityModel() {
121                    SystemEventImpl systemEventImpl = new SystemEventImpl();
122    
123                    systemEventImpl.setMvccVersion(mvccVersion);
124                    systemEventImpl.setSystemEventId(systemEventId);
125                    systemEventImpl.setGroupId(groupId);
126                    systemEventImpl.setCompanyId(companyId);
127                    systemEventImpl.setUserId(userId);
128    
129                    if (userName == null) {
130                            systemEventImpl.setUserName(StringPool.BLANK);
131                    }
132                    else {
133                            systemEventImpl.setUserName(userName);
134                    }
135    
136                    if (createDate == Long.MIN_VALUE) {
137                            systemEventImpl.setCreateDate(null);
138                    }
139                    else {
140                            systemEventImpl.setCreateDate(new Date(createDate));
141                    }
142    
143                    systemEventImpl.setClassNameId(classNameId);
144                    systemEventImpl.setClassPK(classPK);
145    
146                    if (classUuid == null) {
147                            systemEventImpl.setClassUuid(StringPool.BLANK);
148                    }
149                    else {
150                            systemEventImpl.setClassUuid(classUuid);
151                    }
152    
153                    systemEventImpl.setReferrerClassNameId(referrerClassNameId);
154                    systemEventImpl.setParentSystemEventId(parentSystemEventId);
155                    systemEventImpl.setSystemEventSetKey(systemEventSetKey);
156                    systemEventImpl.setType(type);
157    
158                    if (extraData == null) {
159                            systemEventImpl.setExtraData(StringPool.BLANK);
160                    }
161                    else {
162                            systemEventImpl.setExtraData(extraData);
163                    }
164    
165                    systemEventImpl.resetOriginalValues();
166    
167                    return systemEventImpl;
168            }
169    
170            @Override
171            public void readExternal(ObjectInput objectInput) throws IOException {
172                    mvccVersion = objectInput.readLong();
173                    systemEventId = objectInput.readLong();
174                    groupId = objectInput.readLong();
175                    companyId = objectInput.readLong();
176                    userId = objectInput.readLong();
177                    userName = objectInput.readUTF();
178                    createDate = objectInput.readLong();
179                    classNameId = objectInput.readLong();
180                    classPK = objectInput.readLong();
181                    classUuid = objectInput.readUTF();
182                    referrerClassNameId = objectInput.readLong();
183                    parentSystemEventId = objectInput.readLong();
184                    systemEventSetKey = objectInput.readLong();
185                    type = objectInput.readInt();
186                    extraData = objectInput.readUTF();
187            }
188    
189            @Override
190            public void writeExternal(ObjectOutput objectOutput)
191                    throws IOException {
192                    objectOutput.writeLong(mvccVersion);
193                    objectOutput.writeLong(systemEventId);
194                    objectOutput.writeLong(groupId);
195                    objectOutput.writeLong(companyId);
196                    objectOutput.writeLong(userId);
197    
198                    if (userName == null) {
199                            objectOutput.writeUTF(StringPool.BLANK);
200                    }
201                    else {
202                            objectOutput.writeUTF(userName);
203                    }
204    
205                    objectOutput.writeLong(createDate);
206                    objectOutput.writeLong(classNameId);
207                    objectOutput.writeLong(classPK);
208    
209                    if (classUuid == null) {
210                            objectOutput.writeUTF(StringPool.BLANK);
211                    }
212                    else {
213                            objectOutput.writeUTF(classUuid);
214                    }
215    
216                    objectOutput.writeLong(referrerClassNameId);
217                    objectOutput.writeLong(parentSystemEventId);
218                    objectOutput.writeLong(systemEventSetKey);
219                    objectOutput.writeInt(type);
220    
221                    if (extraData == null) {
222                            objectOutput.writeUTF(StringPool.BLANK);
223                    }
224                    else {
225                            objectOutput.writeUTF(extraData);
226                    }
227            }
228    
229            public long mvccVersion;
230            public long systemEventId;
231            public long groupId;
232            public long companyId;
233            public long userId;
234            public String userName;
235            public long createDate;
236            public long classNameId;
237            public long classPK;
238            public String classUuid;
239            public long referrerClassNameId;
240            public long parentSystemEventId;
241            public long systemEventSetKey;
242            public int type;
243            public String extraData;
244    }