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.MDRAction;
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 MDRAction in entity cache.
035     *
036     * @author Edward C. Han
037     * @see MDRAction
038     * @generated
039     */
040    @ProviderType
041    public class MDRActionCacheModel implements CacheModel<MDRAction>,
042            Externalizable {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof MDRActionCacheModel)) {
050                            return false;
051                    }
052    
053                    MDRActionCacheModel mdrActionCacheModel = (MDRActionCacheModel)obj;
054    
055                    if (actionId == mdrActionCacheModel.actionId) {
056                            return true;
057                    }
058    
059                    return false;
060            }
061    
062            @Override
063            public int hashCode() {
064                    return HashUtil.hash(0, actionId);
065            }
066    
067            @Override
068            public String toString() {
069                    StringBundler sb = new StringBundler(31);
070    
071                    sb.append("{uuid=");
072                    sb.append(uuid);
073                    sb.append(", actionId=");
074                    sb.append(actionId);
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(", classNameId=");
088                    sb.append(classNameId);
089                    sb.append(", classPK=");
090                    sb.append(classPK);
091                    sb.append(", ruleGroupInstanceId=");
092                    sb.append(ruleGroupInstanceId);
093                    sb.append(", name=");
094                    sb.append(name);
095                    sb.append(", description=");
096                    sb.append(description);
097                    sb.append(", type=");
098                    sb.append(type);
099                    sb.append(", typeSettings=");
100                    sb.append(typeSettings);
101                    sb.append("}");
102    
103                    return sb.toString();
104            }
105    
106            @Override
107            public MDRAction toEntityModel() {
108                    MDRActionImpl mdrActionImpl = new MDRActionImpl();
109    
110                    if (uuid == null) {
111                            mdrActionImpl.setUuid(StringPool.BLANK);
112                    }
113                    else {
114                            mdrActionImpl.setUuid(uuid);
115                    }
116    
117                    mdrActionImpl.setActionId(actionId);
118                    mdrActionImpl.setGroupId(groupId);
119                    mdrActionImpl.setCompanyId(companyId);
120                    mdrActionImpl.setUserId(userId);
121    
122                    if (userName == null) {
123                            mdrActionImpl.setUserName(StringPool.BLANK);
124                    }
125                    else {
126                            mdrActionImpl.setUserName(userName);
127                    }
128    
129                    if (createDate == Long.MIN_VALUE) {
130                            mdrActionImpl.setCreateDate(null);
131                    }
132                    else {
133                            mdrActionImpl.setCreateDate(new Date(createDate));
134                    }
135    
136                    if (modifiedDate == Long.MIN_VALUE) {
137                            mdrActionImpl.setModifiedDate(null);
138                    }
139                    else {
140                            mdrActionImpl.setModifiedDate(new Date(modifiedDate));
141                    }
142    
143                    mdrActionImpl.setClassNameId(classNameId);
144                    mdrActionImpl.setClassPK(classPK);
145                    mdrActionImpl.setRuleGroupInstanceId(ruleGroupInstanceId);
146    
147                    if (name == null) {
148                            mdrActionImpl.setName(StringPool.BLANK);
149                    }
150                    else {
151                            mdrActionImpl.setName(name);
152                    }
153    
154                    if (description == null) {
155                            mdrActionImpl.setDescription(StringPool.BLANK);
156                    }
157                    else {
158                            mdrActionImpl.setDescription(description);
159                    }
160    
161                    if (type == null) {
162                            mdrActionImpl.setType(StringPool.BLANK);
163                    }
164                    else {
165                            mdrActionImpl.setType(type);
166                    }
167    
168                    if (typeSettings == null) {
169                            mdrActionImpl.setTypeSettings(StringPool.BLANK);
170                    }
171                    else {
172                            mdrActionImpl.setTypeSettings(typeSettings);
173                    }
174    
175                    mdrActionImpl.resetOriginalValues();
176    
177                    return mdrActionImpl;
178            }
179    
180            @Override
181            public void readExternal(ObjectInput objectInput) throws IOException {
182                    uuid = objectInput.readUTF();
183                    actionId = objectInput.readLong();
184                    groupId = objectInput.readLong();
185                    companyId = objectInput.readLong();
186                    userId = objectInput.readLong();
187                    userName = objectInput.readUTF();
188                    createDate = objectInput.readLong();
189                    modifiedDate = objectInput.readLong();
190                    classNameId = objectInput.readLong();
191                    classPK = objectInput.readLong();
192                    ruleGroupInstanceId = objectInput.readLong();
193                    name = objectInput.readUTF();
194                    description = objectInput.readUTF();
195                    type = objectInput.readUTF();
196                    typeSettings = objectInput.readUTF();
197            }
198    
199            @Override
200            public void writeExternal(ObjectOutput objectOutput)
201                    throws IOException {
202                    if (uuid == null) {
203                            objectOutput.writeUTF(StringPool.BLANK);
204                    }
205                    else {
206                            objectOutput.writeUTF(uuid);
207                    }
208    
209                    objectOutput.writeLong(actionId);
210                    objectOutput.writeLong(groupId);
211                    objectOutput.writeLong(companyId);
212                    objectOutput.writeLong(userId);
213    
214                    if (userName == null) {
215                            objectOutput.writeUTF(StringPool.BLANK);
216                    }
217                    else {
218                            objectOutput.writeUTF(userName);
219                    }
220    
221                    objectOutput.writeLong(createDate);
222                    objectOutput.writeLong(modifiedDate);
223                    objectOutput.writeLong(classNameId);
224                    objectOutput.writeLong(classPK);
225                    objectOutput.writeLong(ruleGroupInstanceId);
226    
227                    if (name == null) {
228                            objectOutput.writeUTF(StringPool.BLANK);
229                    }
230                    else {
231                            objectOutput.writeUTF(name);
232                    }
233    
234                    if (description == null) {
235                            objectOutput.writeUTF(StringPool.BLANK);
236                    }
237                    else {
238                            objectOutput.writeUTF(description);
239                    }
240    
241                    if (type == null) {
242                            objectOutput.writeUTF(StringPool.BLANK);
243                    }
244                    else {
245                            objectOutput.writeUTF(type);
246                    }
247    
248                    if (typeSettings == null) {
249                            objectOutput.writeUTF(StringPool.BLANK);
250                    }
251                    else {
252                            objectOutput.writeUTF(typeSettings);
253                    }
254            }
255    
256            public String uuid;
257            public long actionId;
258            public long groupId;
259            public long companyId;
260            public long userId;
261            public String userName;
262            public long createDate;
263            public long modifiedDate;
264            public long classNameId;
265            public long classPK;
266            public long ruleGroupInstanceId;
267            public String name;
268            public String description;
269            public String type;
270            public String typeSettings;
271    }