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.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            @Override
069            public MDRRuleGroup toEntityModel() {
070                    MDRRuleGroupImpl mdrRuleGroupImpl = new MDRRuleGroupImpl();
071    
072                    if (uuid == null) {
073                            mdrRuleGroupImpl.setUuid(StringPool.BLANK);
074                    }
075                    else {
076                            mdrRuleGroupImpl.setUuid(uuid);
077                    }
078    
079                    mdrRuleGroupImpl.setRuleGroupId(ruleGroupId);
080                    mdrRuleGroupImpl.setGroupId(groupId);
081                    mdrRuleGroupImpl.setCompanyId(companyId);
082                    mdrRuleGroupImpl.setUserId(userId);
083    
084                    if (userName == null) {
085                            mdrRuleGroupImpl.setUserName(StringPool.BLANK);
086                    }
087                    else {
088                            mdrRuleGroupImpl.setUserName(userName);
089                    }
090    
091                    if (createDate == Long.MIN_VALUE) {
092                            mdrRuleGroupImpl.setCreateDate(null);
093                    }
094                    else {
095                            mdrRuleGroupImpl.setCreateDate(new Date(createDate));
096                    }
097    
098                    if (modifiedDate == Long.MIN_VALUE) {
099                            mdrRuleGroupImpl.setModifiedDate(null);
100                    }
101                    else {
102                            mdrRuleGroupImpl.setModifiedDate(new Date(modifiedDate));
103                    }
104    
105                    if (name == null) {
106                            mdrRuleGroupImpl.setName(StringPool.BLANK);
107                    }
108                    else {
109                            mdrRuleGroupImpl.setName(name);
110                    }
111    
112                    if (description == null) {
113                            mdrRuleGroupImpl.setDescription(StringPool.BLANK);
114                    }
115                    else {
116                            mdrRuleGroupImpl.setDescription(description);
117                    }
118    
119                    mdrRuleGroupImpl.resetOriginalValues();
120    
121                    return mdrRuleGroupImpl;
122            }
123    
124            @Override
125            public void readExternal(ObjectInput objectInput) throws IOException {
126                    uuid = objectInput.readUTF();
127                    ruleGroupId = objectInput.readLong();
128                    groupId = objectInput.readLong();
129                    companyId = objectInput.readLong();
130                    userId = objectInput.readLong();
131                    userName = objectInput.readUTF();
132                    createDate = objectInput.readLong();
133                    modifiedDate = objectInput.readLong();
134                    name = objectInput.readUTF();
135                    description = objectInput.readUTF();
136            }
137    
138            @Override
139            public void writeExternal(ObjectOutput objectOutput)
140                    throws IOException {
141                    if (uuid == null) {
142                            objectOutput.writeUTF(StringPool.BLANK);
143                    }
144                    else {
145                            objectOutput.writeUTF(uuid);
146                    }
147    
148                    objectOutput.writeLong(ruleGroupId);
149                    objectOutput.writeLong(groupId);
150                    objectOutput.writeLong(companyId);
151                    objectOutput.writeLong(userId);
152    
153                    if (userName == null) {
154                            objectOutput.writeUTF(StringPool.BLANK);
155                    }
156                    else {
157                            objectOutput.writeUTF(userName);
158                    }
159    
160                    objectOutput.writeLong(createDate);
161                    objectOutput.writeLong(modifiedDate);
162    
163                    if (name == null) {
164                            objectOutput.writeUTF(StringPool.BLANK);
165                    }
166                    else {
167                            objectOutput.writeUTF(name);
168                    }
169    
170                    if (description == null) {
171                            objectOutput.writeUTF(StringPool.BLANK);
172                    }
173                    else {
174                            objectOutput.writeUTF(description);
175                    }
176            }
177    
178            public String uuid;
179            public long ruleGroupId;
180            public long groupId;
181            public long companyId;
182            public long userId;
183            public String userName;
184            public long createDate;
185            public long modifiedDate;
186            public String name;
187            public String description;
188    }