001    /**
002     * Copyright (c) 2000-2013 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 com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    import com.liferay.portal.model.Subscription;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    import java.util.Date;
028    
029    /**
030     * The cache model class for representing Subscription in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see Subscription
034     * @generated
035     */
036    public class SubscriptionCacheModel implements CacheModel<Subscription>,
037            Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(19);
041    
042                    sb.append("{subscriptionId=");
043                    sb.append(subscriptionId);
044                    sb.append(", companyId=");
045                    sb.append(companyId);
046                    sb.append(", userId=");
047                    sb.append(userId);
048                    sb.append(", userName=");
049                    sb.append(userName);
050                    sb.append(", createDate=");
051                    sb.append(createDate);
052                    sb.append(", modifiedDate=");
053                    sb.append(modifiedDate);
054                    sb.append(", classNameId=");
055                    sb.append(classNameId);
056                    sb.append(", classPK=");
057                    sb.append(classPK);
058                    sb.append(", frequency=");
059                    sb.append(frequency);
060                    sb.append("}");
061    
062                    return sb.toString();
063            }
064    
065            public Subscription toEntityModel() {
066                    SubscriptionImpl subscriptionImpl = new SubscriptionImpl();
067    
068                    subscriptionImpl.setSubscriptionId(subscriptionId);
069                    subscriptionImpl.setCompanyId(companyId);
070                    subscriptionImpl.setUserId(userId);
071    
072                    if (userName == null) {
073                            subscriptionImpl.setUserName(StringPool.BLANK);
074                    }
075                    else {
076                            subscriptionImpl.setUserName(userName);
077                    }
078    
079                    if (createDate == Long.MIN_VALUE) {
080                            subscriptionImpl.setCreateDate(null);
081                    }
082                    else {
083                            subscriptionImpl.setCreateDate(new Date(createDate));
084                    }
085    
086                    if (modifiedDate == Long.MIN_VALUE) {
087                            subscriptionImpl.setModifiedDate(null);
088                    }
089                    else {
090                            subscriptionImpl.setModifiedDate(new Date(modifiedDate));
091                    }
092    
093                    subscriptionImpl.setClassNameId(classNameId);
094                    subscriptionImpl.setClassPK(classPK);
095    
096                    if (frequency == null) {
097                            subscriptionImpl.setFrequency(StringPool.BLANK);
098                    }
099                    else {
100                            subscriptionImpl.setFrequency(frequency);
101                    }
102    
103                    subscriptionImpl.resetOriginalValues();
104    
105                    return subscriptionImpl;
106            }
107    
108            public void readExternal(ObjectInput objectInput) throws IOException {
109                    subscriptionId = objectInput.readLong();
110                    companyId = objectInput.readLong();
111                    userId = objectInput.readLong();
112                    userName = objectInput.readUTF();
113                    createDate = objectInput.readLong();
114                    modifiedDate = objectInput.readLong();
115                    classNameId = objectInput.readLong();
116                    classPK = objectInput.readLong();
117                    frequency = objectInput.readUTF();
118            }
119    
120            public void writeExternal(ObjectOutput objectOutput)
121                    throws IOException {
122                    objectOutput.writeLong(subscriptionId);
123                    objectOutput.writeLong(companyId);
124                    objectOutput.writeLong(userId);
125    
126                    if (userName == null) {
127                            objectOutput.writeUTF(StringPool.BLANK);
128                    }
129                    else {
130                            objectOutput.writeUTF(userName);
131                    }
132    
133                    objectOutput.writeLong(createDate);
134                    objectOutput.writeLong(modifiedDate);
135                    objectOutput.writeLong(classNameId);
136                    objectOutput.writeLong(classPK);
137    
138                    if (frequency == null) {
139                            objectOutput.writeUTF(StringPool.BLANK);
140                    }
141                    else {
142                            objectOutput.writeUTF(frequency);
143                    }
144            }
145    
146            public long subscriptionId;
147            public long companyId;
148            public long userId;
149            public String userName;
150            public long createDate;
151            public long modifiedDate;
152            public long classNameId;
153            public long classPK;
154            public String frequency;
155    }