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