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.ratings.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.ratings.model.RatingsEntry;
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 RatingsEntry in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see RatingsEntry
038     * @generated
039     */
040    @ProviderType
041    public class RatingsEntryCacheModel implements CacheModel<RatingsEntry>,
042            Externalizable {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof RatingsEntryCacheModel)) {
050                            return false;
051                    }
052    
053                    RatingsEntryCacheModel ratingsEntryCacheModel = (RatingsEntryCacheModel)obj;
054    
055                    if (entryId == ratingsEntryCacheModel.entryId) {
056                            return true;
057                    }
058    
059                    return false;
060            }
061    
062            @Override
063            public int hashCode() {
064                    return HashUtil.hash(0, entryId);
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(", entryId=");
074                    sb.append(entryId);
075                    sb.append(", companyId=");
076                    sb.append(companyId);
077                    sb.append(", userId=");
078                    sb.append(userId);
079                    sb.append(", userName=");
080                    sb.append(userName);
081                    sb.append(", createDate=");
082                    sb.append(createDate);
083                    sb.append(", modifiedDate=");
084                    sb.append(modifiedDate);
085                    sb.append(", classNameId=");
086                    sb.append(classNameId);
087                    sb.append(", classPK=");
088                    sb.append(classPK);
089                    sb.append(", score=");
090                    sb.append(score);
091                    sb.append("}");
092    
093                    return sb.toString();
094            }
095    
096            @Override
097            public RatingsEntry toEntityModel() {
098                    RatingsEntryImpl ratingsEntryImpl = new RatingsEntryImpl();
099    
100                    if (uuid == null) {
101                            ratingsEntryImpl.setUuid(StringPool.BLANK);
102                    }
103                    else {
104                            ratingsEntryImpl.setUuid(uuid);
105                    }
106    
107                    ratingsEntryImpl.setEntryId(entryId);
108                    ratingsEntryImpl.setCompanyId(companyId);
109                    ratingsEntryImpl.setUserId(userId);
110    
111                    if (userName == null) {
112                            ratingsEntryImpl.setUserName(StringPool.BLANK);
113                    }
114                    else {
115                            ratingsEntryImpl.setUserName(userName);
116                    }
117    
118                    if (createDate == Long.MIN_VALUE) {
119                            ratingsEntryImpl.setCreateDate(null);
120                    }
121                    else {
122                            ratingsEntryImpl.setCreateDate(new Date(createDate));
123                    }
124    
125                    if (modifiedDate == Long.MIN_VALUE) {
126                            ratingsEntryImpl.setModifiedDate(null);
127                    }
128                    else {
129                            ratingsEntryImpl.setModifiedDate(new Date(modifiedDate));
130                    }
131    
132                    ratingsEntryImpl.setClassNameId(classNameId);
133                    ratingsEntryImpl.setClassPK(classPK);
134                    ratingsEntryImpl.setScore(score);
135    
136                    ratingsEntryImpl.resetOriginalValues();
137    
138                    return ratingsEntryImpl;
139            }
140    
141            @Override
142            public void readExternal(ObjectInput objectInput) throws IOException {
143                    uuid = objectInput.readUTF();
144                    entryId = objectInput.readLong();
145                    companyId = objectInput.readLong();
146                    userId = objectInput.readLong();
147                    userName = objectInput.readUTF();
148                    createDate = objectInput.readLong();
149                    modifiedDate = objectInput.readLong();
150                    classNameId = objectInput.readLong();
151                    classPK = objectInput.readLong();
152                    score = objectInput.readDouble();
153            }
154    
155            @Override
156            public void writeExternal(ObjectOutput objectOutput)
157                    throws IOException {
158                    if (uuid == null) {
159                            objectOutput.writeUTF(StringPool.BLANK);
160                    }
161                    else {
162                            objectOutput.writeUTF(uuid);
163                    }
164    
165                    objectOutput.writeLong(entryId);
166                    objectOutput.writeLong(companyId);
167                    objectOutput.writeLong(userId);
168    
169                    if (userName == null) {
170                            objectOutput.writeUTF(StringPool.BLANK);
171                    }
172                    else {
173                            objectOutput.writeUTF(userName);
174                    }
175    
176                    objectOutput.writeLong(createDate);
177                    objectOutput.writeLong(modifiedDate);
178                    objectOutput.writeLong(classNameId);
179                    objectOutput.writeLong(classPK);
180                    objectOutput.writeDouble(score);
181            }
182    
183            public String uuid;
184            public long entryId;
185            public long companyId;
186            public long userId;
187            public String userName;
188            public long createDate;
189            public long modifiedDate;
190            public long classNameId;
191            public long classPK;
192            public double score;
193    }