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