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