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.portal.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.Account;
023    import com.liferay.portal.model.CacheModel;
024    import com.liferay.portal.model.MVCCModel;
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 Account in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see Account
038     * @generated
039     */
040    @ProviderType
041    public class AccountCacheModel implements CacheModel<Account>, Externalizable,
042            MVCCModel {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof AccountCacheModel)) {
050                            return false;
051                    }
052    
053                    AccountCacheModel accountCacheModel = (AccountCacheModel)obj;
054    
055                    if ((accountId == accountCacheModel.accountId) &&
056                                    (mvccVersion == accountCacheModel.mvccVersion)) {
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hashCode = HashUtil.hash(0, accountId);
066    
067                    return HashUtil.hash(hashCode, mvccVersion);
068            }
069    
070            @Override
071            public long getMvccVersion() {
072                    return mvccVersion;
073            }
074    
075            @Override
076            public void setMvccVersion(long mvccVersion) {
077                    this.mvccVersion = mvccVersion;
078            }
079    
080            @Override
081            public String toString() {
082                    StringBundler sb = new StringBundler(35);
083    
084                    sb.append("{mvccVersion=");
085                    sb.append(mvccVersion);
086                    sb.append(", accountId=");
087                    sb.append(accountId);
088                    sb.append(", companyId=");
089                    sb.append(companyId);
090                    sb.append(", userId=");
091                    sb.append(userId);
092                    sb.append(", userName=");
093                    sb.append(userName);
094                    sb.append(", createDate=");
095                    sb.append(createDate);
096                    sb.append(", modifiedDate=");
097                    sb.append(modifiedDate);
098                    sb.append(", parentAccountId=");
099                    sb.append(parentAccountId);
100                    sb.append(", name=");
101                    sb.append(name);
102                    sb.append(", legalName=");
103                    sb.append(legalName);
104                    sb.append(", legalId=");
105                    sb.append(legalId);
106                    sb.append(", legalType=");
107                    sb.append(legalType);
108                    sb.append(", sicCode=");
109                    sb.append(sicCode);
110                    sb.append(", tickerSymbol=");
111                    sb.append(tickerSymbol);
112                    sb.append(", industry=");
113                    sb.append(industry);
114                    sb.append(", type=");
115                    sb.append(type);
116                    sb.append(", size=");
117                    sb.append(size);
118                    sb.append("}");
119    
120                    return sb.toString();
121            }
122    
123            @Override
124            public Account toEntityModel() {
125                    AccountImpl accountImpl = new AccountImpl();
126    
127                    accountImpl.setMvccVersion(mvccVersion);
128                    accountImpl.setAccountId(accountId);
129                    accountImpl.setCompanyId(companyId);
130                    accountImpl.setUserId(userId);
131    
132                    if (userName == null) {
133                            accountImpl.setUserName(StringPool.BLANK);
134                    }
135                    else {
136                            accountImpl.setUserName(userName);
137                    }
138    
139                    if (createDate == Long.MIN_VALUE) {
140                            accountImpl.setCreateDate(null);
141                    }
142                    else {
143                            accountImpl.setCreateDate(new Date(createDate));
144                    }
145    
146                    if (modifiedDate == Long.MIN_VALUE) {
147                            accountImpl.setModifiedDate(null);
148                    }
149                    else {
150                            accountImpl.setModifiedDate(new Date(modifiedDate));
151                    }
152    
153                    accountImpl.setParentAccountId(parentAccountId);
154    
155                    if (name == null) {
156                            accountImpl.setName(StringPool.BLANK);
157                    }
158                    else {
159                            accountImpl.setName(name);
160                    }
161    
162                    if (legalName == null) {
163                            accountImpl.setLegalName(StringPool.BLANK);
164                    }
165                    else {
166                            accountImpl.setLegalName(legalName);
167                    }
168    
169                    if (legalId == null) {
170                            accountImpl.setLegalId(StringPool.BLANK);
171                    }
172                    else {
173                            accountImpl.setLegalId(legalId);
174                    }
175    
176                    if (legalType == null) {
177                            accountImpl.setLegalType(StringPool.BLANK);
178                    }
179                    else {
180                            accountImpl.setLegalType(legalType);
181                    }
182    
183                    if (sicCode == null) {
184                            accountImpl.setSicCode(StringPool.BLANK);
185                    }
186                    else {
187                            accountImpl.setSicCode(sicCode);
188                    }
189    
190                    if (tickerSymbol == null) {
191                            accountImpl.setTickerSymbol(StringPool.BLANK);
192                    }
193                    else {
194                            accountImpl.setTickerSymbol(tickerSymbol);
195                    }
196    
197                    if (industry == null) {
198                            accountImpl.setIndustry(StringPool.BLANK);
199                    }
200                    else {
201                            accountImpl.setIndustry(industry);
202                    }
203    
204                    if (type == null) {
205                            accountImpl.setType(StringPool.BLANK);
206                    }
207                    else {
208                            accountImpl.setType(type);
209                    }
210    
211                    if (size == null) {
212                            accountImpl.setSize(StringPool.BLANK);
213                    }
214                    else {
215                            accountImpl.setSize(size);
216                    }
217    
218                    accountImpl.resetOriginalValues();
219    
220                    return accountImpl;
221            }
222    
223            @Override
224            public void readExternal(ObjectInput objectInput) throws IOException {
225                    mvccVersion = objectInput.readLong();
226                    accountId = objectInput.readLong();
227                    companyId = objectInput.readLong();
228                    userId = objectInput.readLong();
229                    userName = objectInput.readUTF();
230                    createDate = objectInput.readLong();
231                    modifiedDate = objectInput.readLong();
232                    parentAccountId = objectInput.readLong();
233                    name = objectInput.readUTF();
234                    legalName = objectInput.readUTF();
235                    legalId = objectInput.readUTF();
236                    legalType = objectInput.readUTF();
237                    sicCode = objectInput.readUTF();
238                    tickerSymbol = objectInput.readUTF();
239                    industry = objectInput.readUTF();
240                    type = objectInput.readUTF();
241                    size = objectInput.readUTF();
242            }
243    
244            @Override
245            public void writeExternal(ObjectOutput objectOutput)
246                    throws IOException {
247                    objectOutput.writeLong(mvccVersion);
248                    objectOutput.writeLong(accountId);
249                    objectOutput.writeLong(companyId);
250                    objectOutput.writeLong(userId);
251    
252                    if (userName == null) {
253                            objectOutput.writeUTF(StringPool.BLANK);
254                    }
255                    else {
256                            objectOutput.writeUTF(userName);
257                    }
258    
259                    objectOutput.writeLong(createDate);
260                    objectOutput.writeLong(modifiedDate);
261                    objectOutput.writeLong(parentAccountId);
262    
263                    if (name == null) {
264                            objectOutput.writeUTF(StringPool.BLANK);
265                    }
266                    else {
267                            objectOutput.writeUTF(name);
268                    }
269    
270                    if (legalName == null) {
271                            objectOutput.writeUTF(StringPool.BLANK);
272                    }
273                    else {
274                            objectOutput.writeUTF(legalName);
275                    }
276    
277                    if (legalId == null) {
278                            objectOutput.writeUTF(StringPool.BLANK);
279                    }
280                    else {
281                            objectOutput.writeUTF(legalId);
282                    }
283    
284                    if (legalType == null) {
285                            objectOutput.writeUTF(StringPool.BLANK);
286                    }
287                    else {
288                            objectOutput.writeUTF(legalType);
289                    }
290    
291                    if (sicCode == null) {
292                            objectOutput.writeUTF(StringPool.BLANK);
293                    }
294                    else {
295                            objectOutput.writeUTF(sicCode);
296                    }
297    
298                    if (tickerSymbol == null) {
299                            objectOutput.writeUTF(StringPool.BLANK);
300                    }
301                    else {
302                            objectOutput.writeUTF(tickerSymbol);
303                    }
304    
305                    if (industry == null) {
306                            objectOutput.writeUTF(StringPool.BLANK);
307                    }
308                    else {
309                            objectOutput.writeUTF(industry);
310                    }
311    
312                    if (type == null) {
313                            objectOutput.writeUTF(StringPool.BLANK);
314                    }
315                    else {
316                            objectOutput.writeUTF(type);
317                    }
318    
319                    if (size == null) {
320                            objectOutput.writeUTF(StringPool.BLANK);
321                    }
322                    else {
323                            objectOutput.writeUTF(size);
324                    }
325            }
326    
327            public long mvccVersion;
328            public long accountId;
329            public long companyId;
330            public long userId;
331            public String userName;
332            public long createDate;
333            public long modifiedDate;
334            public long parentAccountId;
335            public String name;
336            public String legalName;
337            public String legalId;
338            public String legalType;
339            public String sicCode;
340            public String tickerSymbol;
341            public String industry;
342            public String type;
343            public String size;
344    }