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