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.portlet.mobiledevicerules.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    
021    import com.liferay.portlet.mobiledevicerules.model.MDRRule;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    import java.util.Date;
029    
030    /**
031     * The cache model class for representing MDRRule in entity cache.
032     *
033     * @author Edward C. Han
034     * @see MDRRule
035     * @generated
036     */
037    public class MDRRuleCacheModel implements CacheModel<MDRRule>, Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(27);
041    
042                    sb.append("{uuid=");
043                    sb.append(uuid);
044                    sb.append(", ruleId=");
045                    sb.append(ruleId);
046                    sb.append(", groupId=");
047                    sb.append(groupId);
048                    sb.append(", companyId=");
049                    sb.append(companyId);
050                    sb.append(", userId=");
051                    sb.append(userId);
052                    sb.append(", userName=");
053                    sb.append(userName);
054                    sb.append(", createDate=");
055                    sb.append(createDate);
056                    sb.append(", modifiedDate=");
057                    sb.append(modifiedDate);
058                    sb.append(", ruleGroupId=");
059                    sb.append(ruleGroupId);
060                    sb.append(", name=");
061                    sb.append(name);
062                    sb.append(", description=");
063                    sb.append(description);
064                    sb.append(", type=");
065                    sb.append(type);
066                    sb.append(", typeSettings=");
067                    sb.append(typeSettings);
068                    sb.append("}");
069    
070                    return sb.toString();
071            }
072    
073            public MDRRule toEntityModel() {
074                    MDRRuleImpl mdrRuleImpl = new MDRRuleImpl();
075    
076                    if (uuid == null) {
077                            mdrRuleImpl.setUuid(StringPool.BLANK);
078                    }
079                    else {
080                            mdrRuleImpl.setUuid(uuid);
081                    }
082    
083                    mdrRuleImpl.setRuleId(ruleId);
084                    mdrRuleImpl.setGroupId(groupId);
085                    mdrRuleImpl.setCompanyId(companyId);
086                    mdrRuleImpl.setUserId(userId);
087    
088                    if (userName == null) {
089                            mdrRuleImpl.setUserName(StringPool.BLANK);
090                    }
091                    else {
092                            mdrRuleImpl.setUserName(userName);
093                    }
094    
095                    if (createDate == Long.MIN_VALUE) {
096                            mdrRuleImpl.setCreateDate(null);
097                    }
098                    else {
099                            mdrRuleImpl.setCreateDate(new Date(createDate));
100                    }
101    
102                    if (modifiedDate == Long.MIN_VALUE) {
103                            mdrRuleImpl.setModifiedDate(null);
104                    }
105                    else {
106                            mdrRuleImpl.setModifiedDate(new Date(modifiedDate));
107                    }
108    
109                    mdrRuleImpl.setRuleGroupId(ruleGroupId);
110    
111                    if (name == null) {
112                            mdrRuleImpl.setName(StringPool.BLANK);
113                    }
114                    else {
115                            mdrRuleImpl.setName(name);
116                    }
117    
118                    if (description == null) {
119                            mdrRuleImpl.setDescription(StringPool.BLANK);
120                    }
121                    else {
122                            mdrRuleImpl.setDescription(description);
123                    }
124    
125                    if (type == null) {
126                            mdrRuleImpl.setType(StringPool.BLANK);
127                    }
128                    else {
129                            mdrRuleImpl.setType(type);
130                    }
131    
132                    if (typeSettings == null) {
133                            mdrRuleImpl.setTypeSettings(StringPool.BLANK);
134                    }
135                    else {
136                            mdrRuleImpl.setTypeSettings(typeSettings);
137                    }
138    
139                    mdrRuleImpl.resetOriginalValues();
140    
141                    return mdrRuleImpl;
142            }
143    
144            public void readExternal(ObjectInput objectInput) throws IOException {
145                    uuid = objectInput.readUTF();
146                    ruleId = objectInput.readLong();
147                    groupId = objectInput.readLong();
148                    companyId = objectInput.readLong();
149                    userId = objectInput.readLong();
150                    userName = objectInput.readUTF();
151                    createDate = objectInput.readLong();
152                    modifiedDate = objectInput.readLong();
153                    ruleGroupId = objectInput.readLong();
154                    name = objectInput.readUTF();
155                    description = objectInput.readUTF();
156                    type = objectInput.readUTF();
157                    typeSettings = objectInput.readUTF();
158            }
159    
160            public void writeExternal(ObjectOutput objectOutput)
161                    throws IOException {
162                    if (uuid == null) {
163                            objectOutput.writeUTF(StringPool.BLANK);
164                    }
165                    else {
166                            objectOutput.writeUTF(uuid);
167                    }
168    
169                    objectOutput.writeLong(ruleId);
170                    objectOutput.writeLong(groupId);
171                    objectOutput.writeLong(companyId);
172                    objectOutput.writeLong(userId);
173    
174                    if (userName == null) {
175                            objectOutput.writeUTF(StringPool.BLANK);
176                    }
177                    else {
178                            objectOutput.writeUTF(userName);
179                    }
180    
181                    objectOutput.writeLong(createDate);
182                    objectOutput.writeLong(modifiedDate);
183                    objectOutput.writeLong(ruleGroupId);
184    
185                    if (name == null) {
186                            objectOutput.writeUTF(StringPool.BLANK);
187                    }
188                    else {
189                            objectOutput.writeUTF(name);
190                    }
191    
192                    if (description == null) {
193                            objectOutput.writeUTF(StringPool.BLANK);
194                    }
195                    else {
196                            objectOutput.writeUTF(description);
197                    }
198    
199                    if (type == null) {
200                            objectOutput.writeUTF(StringPool.BLANK);
201                    }
202                    else {
203                            objectOutput.writeUTF(type);
204                    }
205    
206                    if (typeSettings == null) {
207                            objectOutput.writeUTF(StringPool.BLANK);
208                    }
209                    else {
210                            objectOutput.writeUTF(typeSettings);
211                    }
212            }
213    
214            public String uuid;
215            public long ruleId;
216            public long groupId;
217            public long companyId;
218            public long userId;
219            public String userName;
220            public long createDate;
221            public long modifiedDate;
222            public long ruleGroupId;
223            public String name;
224            public String description;
225            public String type;
226            public String typeSettings;
227    }