001    /**
002     * Copyright (c) 2000-2012 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.MDRRuleGroup;
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 MDRRuleGroup in entity cache.
032     *
033     * @author Edward C. Han
034     * @see MDRRuleGroup
035     * @generated
036     */
037    public class MDRRuleGroupCacheModel implements CacheModel<MDRRuleGroup>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(21);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", ruleGroupId=");
046                    sb.append(ruleGroupId);
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(", name=");
060                    sb.append(name);
061                    sb.append(", description=");
062                    sb.append(description);
063                    sb.append("}");
064    
065                    return sb.toString();
066            }
067    
068            public MDRRuleGroup toEntityModel() {
069                    MDRRuleGroupImpl mdrRuleGroupImpl = new MDRRuleGroupImpl();
070    
071                    if (uuid == null) {
072                            mdrRuleGroupImpl.setUuid(StringPool.BLANK);
073                    }
074                    else {
075                            mdrRuleGroupImpl.setUuid(uuid);
076                    }
077    
078                    mdrRuleGroupImpl.setRuleGroupId(ruleGroupId);
079                    mdrRuleGroupImpl.setGroupId(groupId);
080                    mdrRuleGroupImpl.setCompanyId(companyId);
081                    mdrRuleGroupImpl.setUserId(userId);
082    
083                    if (userName == null) {
084                            mdrRuleGroupImpl.setUserName(StringPool.BLANK);
085                    }
086                    else {
087                            mdrRuleGroupImpl.setUserName(userName);
088                    }
089    
090                    if (createDate == Long.MIN_VALUE) {
091                            mdrRuleGroupImpl.setCreateDate(null);
092                    }
093                    else {
094                            mdrRuleGroupImpl.setCreateDate(new Date(createDate));
095                    }
096    
097                    if (modifiedDate == Long.MIN_VALUE) {
098                            mdrRuleGroupImpl.setModifiedDate(null);
099                    }
100                    else {
101                            mdrRuleGroupImpl.setModifiedDate(new Date(modifiedDate));
102                    }
103    
104                    if (name == null) {
105                            mdrRuleGroupImpl.setName(StringPool.BLANK);
106                    }
107                    else {
108                            mdrRuleGroupImpl.setName(name);
109                    }
110    
111                    if (description == null) {
112                            mdrRuleGroupImpl.setDescription(StringPool.BLANK);
113                    }
114                    else {
115                            mdrRuleGroupImpl.setDescription(description);
116                    }
117    
118                    mdrRuleGroupImpl.resetOriginalValues();
119    
120                    return mdrRuleGroupImpl;
121            }
122    
123            public void readExternal(ObjectInput objectInput) throws IOException {
124                    uuid = objectInput.readUTF();
125                    ruleGroupId = objectInput.readLong();
126                    groupId = objectInput.readLong();
127                    companyId = objectInput.readLong();
128                    userId = objectInput.readLong();
129                    userName = objectInput.readUTF();
130                    createDate = objectInput.readLong();
131                    modifiedDate = objectInput.readLong();
132                    name = objectInput.readUTF();
133                    description = objectInput.readUTF();
134            }
135    
136            public void writeExternal(ObjectOutput objectOutput)
137                    throws IOException {
138                    if (uuid == null) {
139                            objectOutput.writeUTF(StringPool.BLANK);
140                    }
141                    else {
142                            objectOutput.writeUTF(uuid);
143                    }
144    
145                    objectOutput.writeLong(ruleGroupId);
146                    objectOutput.writeLong(groupId);
147                    objectOutput.writeLong(companyId);
148                    objectOutput.writeLong(userId);
149    
150                    if (userName == null) {
151                            objectOutput.writeUTF(StringPool.BLANK);
152                    }
153                    else {
154                            objectOutput.writeUTF(userName);
155                    }
156    
157                    objectOutput.writeLong(createDate);
158                    objectOutput.writeLong(modifiedDate);
159    
160                    if (name == null) {
161                            objectOutput.writeUTF(StringPool.BLANK);
162                    }
163                    else {
164                            objectOutput.writeUTF(name);
165                    }
166    
167                    if (description == null) {
168                            objectOutput.writeUTF(StringPool.BLANK);
169                    }
170                    else {
171                            objectOutput.writeUTF(description);
172                    }
173            }
174    
175            public String uuid;
176            public long ruleGroupId;
177            public long groupId;
178            public long companyId;
179            public long userId;
180            public String userName;
181            public long createDate;
182            public long modifiedDate;
183            public String name;
184            public String description;
185    }