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            @Override
079            public MDRAction toEntityModel() {
080                    MDRActionImpl mdrActionImpl = new MDRActionImpl();
081    
082                    if (uuid == null) {
083                            mdrActionImpl.setUuid(StringPool.BLANK);
084                    }
085                    else {
086                            mdrActionImpl.setUuid(uuid);
087                    }
088    
089                    mdrActionImpl.setActionId(actionId);
090                    mdrActionImpl.setGroupId(groupId);
091                    mdrActionImpl.setCompanyId(companyId);
092                    mdrActionImpl.setUserId(userId);
093    
094                    if (userName == null) {
095                            mdrActionImpl.setUserName(StringPool.BLANK);
096                    }
097                    else {
098                            mdrActionImpl.setUserName(userName);
099                    }
100    
101                    if (createDate == Long.MIN_VALUE) {
102                            mdrActionImpl.setCreateDate(null);
103                    }
104                    else {
105                            mdrActionImpl.setCreateDate(new Date(createDate));
106                    }
107    
108                    if (modifiedDate == Long.MIN_VALUE) {
109                            mdrActionImpl.setModifiedDate(null);
110                    }
111                    else {
112                            mdrActionImpl.setModifiedDate(new Date(modifiedDate));
113                    }
114    
115                    mdrActionImpl.setClassNameId(classNameId);
116                    mdrActionImpl.setClassPK(classPK);
117                    mdrActionImpl.setRuleGroupInstanceId(ruleGroupInstanceId);
118    
119                    if (name == null) {
120                            mdrActionImpl.setName(StringPool.BLANK);
121                    }
122                    else {
123                            mdrActionImpl.setName(name);
124                    }
125    
126                    if (description == null) {
127                            mdrActionImpl.setDescription(StringPool.BLANK);
128                    }
129                    else {
130                            mdrActionImpl.setDescription(description);
131                    }
132    
133                    if (type == null) {
134                            mdrActionImpl.setType(StringPool.BLANK);
135                    }
136                    else {
137                            mdrActionImpl.setType(type);
138                    }
139    
140                    if (typeSettings == null) {
141                            mdrActionImpl.setTypeSettings(StringPool.BLANK);
142                    }
143                    else {
144                            mdrActionImpl.setTypeSettings(typeSettings);
145                    }
146    
147                    mdrActionImpl.resetOriginalValues();
148    
149                    return mdrActionImpl;
150            }
151    
152            @Override
153            public void readExternal(ObjectInput objectInput) throws IOException {
154                    uuid = objectInput.readUTF();
155                    actionId = objectInput.readLong();
156                    groupId = objectInput.readLong();
157                    companyId = objectInput.readLong();
158                    userId = objectInput.readLong();
159                    userName = objectInput.readUTF();
160                    createDate = objectInput.readLong();
161                    modifiedDate = objectInput.readLong();
162                    classNameId = objectInput.readLong();
163                    classPK = objectInput.readLong();
164                    ruleGroupInstanceId = objectInput.readLong();
165                    name = objectInput.readUTF();
166                    description = objectInput.readUTF();
167                    type = objectInput.readUTF();
168                    typeSettings = objectInput.readUTF();
169            }
170    
171            @Override
172            public void writeExternal(ObjectOutput objectOutput)
173                    throws IOException {
174                    if (uuid == null) {
175                            objectOutput.writeUTF(StringPool.BLANK);
176                    }
177                    else {
178                            objectOutput.writeUTF(uuid);
179                    }
180    
181                    objectOutput.writeLong(actionId);
182                    objectOutput.writeLong(groupId);
183                    objectOutput.writeLong(companyId);
184                    objectOutput.writeLong(userId);
185    
186                    if (userName == null) {
187                            objectOutput.writeUTF(StringPool.BLANK);
188                    }
189                    else {
190                            objectOutput.writeUTF(userName);
191                    }
192    
193                    objectOutput.writeLong(createDate);
194                    objectOutput.writeLong(modifiedDate);
195                    objectOutput.writeLong(classNameId);
196                    objectOutput.writeLong(classPK);
197                    objectOutput.writeLong(ruleGroupInstanceId);
198    
199                    if (name == null) {
200                            objectOutput.writeUTF(StringPool.BLANK);
201                    }
202                    else {
203                            objectOutput.writeUTF(name);
204                    }
205    
206                    if (description == null) {
207                            objectOutput.writeUTF(StringPool.BLANK);
208                    }
209                    else {
210                            objectOutput.writeUTF(description);
211                    }
212    
213                    if (type == null) {
214                            objectOutput.writeUTF(StringPool.BLANK);
215                    }
216                    else {
217                            objectOutput.writeUTF(type);
218                    }
219    
220                    if (typeSettings == null) {
221                            objectOutput.writeUTF(StringPool.BLANK);
222                    }
223                    else {
224                            objectOutput.writeUTF(typeSettings);
225                    }
226            }
227    
228            public String uuid;
229            public long actionId;
230            public long groupId;
231            public long companyId;
232            public long userId;
233            public String userName;
234            public long createDate;
235            public long modifiedDate;
236            public long classNameId;
237            public long classPK;
238            public long ruleGroupInstanceId;
239            public String name;
240            public String description;
241            public String type;
242            public String typeSettings;
243    }