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