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            @Override
066            public Subscription toEntityModel() {
067                    SubscriptionImpl subscriptionImpl = new SubscriptionImpl();
068    
069                    subscriptionImpl.setSubscriptionId(subscriptionId);
070                    subscriptionImpl.setCompanyId(companyId);
071                    subscriptionImpl.setUserId(userId);
072    
073                    if (userName == null) {
074                            subscriptionImpl.setUserName(StringPool.BLANK);
075                    }
076                    else {
077                            subscriptionImpl.setUserName(userName);
078                    }
079    
080                    if (createDate == Long.MIN_VALUE) {
081                            subscriptionImpl.setCreateDate(null);
082                    }
083                    else {
084                            subscriptionImpl.setCreateDate(new Date(createDate));
085                    }
086    
087                    if (modifiedDate == Long.MIN_VALUE) {
088                            subscriptionImpl.setModifiedDate(null);
089                    }
090                    else {
091                            subscriptionImpl.setModifiedDate(new Date(modifiedDate));
092                    }
093    
094                    subscriptionImpl.setClassNameId(classNameId);
095                    subscriptionImpl.setClassPK(classPK);
096    
097                    if (frequency == null) {
098                            subscriptionImpl.setFrequency(StringPool.BLANK);
099                    }
100                    else {
101                            subscriptionImpl.setFrequency(frequency);
102                    }
103    
104                    subscriptionImpl.resetOriginalValues();
105    
106                    return subscriptionImpl;
107            }
108    
109            @Override
110            public void readExternal(ObjectInput objectInput) throws IOException {
111                    subscriptionId = objectInput.readLong();
112                    companyId = objectInput.readLong();
113                    userId = objectInput.readLong();
114                    userName = objectInput.readUTF();
115                    createDate = objectInput.readLong();
116                    modifiedDate = objectInput.readLong();
117                    classNameId = objectInput.readLong();
118                    classPK = objectInput.readLong();
119                    frequency = objectInput.readUTF();
120            }
121    
122            @Override
123            public void writeExternal(ObjectOutput objectOutput)
124                    throws IOException {
125                    objectOutput.writeLong(subscriptionId);
126                    objectOutput.writeLong(companyId);
127                    objectOutput.writeLong(userId);
128    
129                    if (userName == null) {
130                            objectOutput.writeUTF(StringPool.BLANK);
131                    }
132                    else {
133                            objectOutput.writeUTF(userName);
134                    }
135    
136                    objectOutput.writeLong(createDate);
137                    objectOutput.writeLong(modifiedDate);
138                    objectOutput.writeLong(classNameId);
139                    objectOutput.writeLong(classPK);
140    
141                    if (frequency == null) {
142                            objectOutput.writeUTF(StringPool.BLANK);
143                    }
144                    else {
145                            objectOutput.writeUTF(frequency);
146                    }
147            }
148    
149            public long subscriptionId;
150            public long companyId;
151            public long userId;
152            public String userName;
153            public long createDate;
154            public long modifiedDate;
155            public long classNameId;
156            public long classPK;
157            public String frequency;
158    }