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.model.CacheModel;
020    import com.liferay.portal.kernel.model.MVCCModel;
021    import com.liferay.portal.kernel.model.Ticket;
022    import com.liferay.portal.kernel.util.HashUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
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 Ticket in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see Ticket
038     * @generated
039     */
040    @ProviderType
041    public class TicketCacheModel implements CacheModel<Ticket>, Externalizable,
042            MVCCModel {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof TicketCacheModel)) {
050                            return false;
051                    }
052    
053                    TicketCacheModel ticketCacheModel = (TicketCacheModel)obj;
054    
055                    if ((ticketId == ticketCacheModel.ticketId) &&
056                                    (mvccVersion == ticketCacheModel.mvccVersion)) {
057                            return true;
058                    }
059    
060                    return false;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hashCode = HashUtil.hash(0, ticketId);
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(21);
083    
084                    sb.append("{mvccVersion=");
085                    sb.append(mvccVersion);
086                    sb.append(", ticketId=");
087                    sb.append(ticketId);
088                    sb.append(", companyId=");
089                    sb.append(companyId);
090                    sb.append(", createDate=");
091                    sb.append(createDate);
092                    sb.append(", classNameId=");
093                    sb.append(classNameId);
094                    sb.append(", classPK=");
095                    sb.append(classPK);
096                    sb.append(", key=");
097                    sb.append(key);
098                    sb.append(", type=");
099                    sb.append(type);
100                    sb.append(", extraInfo=");
101                    sb.append(extraInfo);
102                    sb.append(", expirationDate=");
103                    sb.append(expirationDate);
104                    sb.append("}");
105    
106                    return sb.toString();
107            }
108    
109            @Override
110            public Ticket toEntityModel() {
111                    TicketImpl ticketImpl = new TicketImpl();
112    
113                    ticketImpl.setMvccVersion(mvccVersion);
114                    ticketImpl.setTicketId(ticketId);
115                    ticketImpl.setCompanyId(companyId);
116    
117                    if (createDate == Long.MIN_VALUE) {
118                            ticketImpl.setCreateDate(null);
119                    }
120                    else {
121                            ticketImpl.setCreateDate(new Date(createDate));
122                    }
123    
124                    ticketImpl.setClassNameId(classNameId);
125                    ticketImpl.setClassPK(classPK);
126    
127                    if (key == null) {
128                            ticketImpl.setKey(StringPool.BLANK);
129                    }
130                    else {
131                            ticketImpl.setKey(key);
132                    }
133    
134                    ticketImpl.setType(type);
135    
136                    if (extraInfo == null) {
137                            ticketImpl.setExtraInfo(StringPool.BLANK);
138                    }
139                    else {
140                            ticketImpl.setExtraInfo(extraInfo);
141                    }
142    
143                    if (expirationDate == Long.MIN_VALUE) {
144                            ticketImpl.setExpirationDate(null);
145                    }
146                    else {
147                            ticketImpl.setExpirationDate(new Date(expirationDate));
148                    }
149    
150                    ticketImpl.resetOriginalValues();
151    
152                    return ticketImpl;
153            }
154    
155            @Override
156            public void readExternal(ObjectInput objectInput) throws IOException {
157                    mvccVersion = objectInput.readLong();
158    
159                    ticketId = objectInput.readLong();
160    
161                    companyId = objectInput.readLong();
162                    createDate = objectInput.readLong();
163    
164                    classNameId = objectInput.readLong();
165    
166                    classPK = objectInput.readLong();
167                    key = objectInput.readUTF();
168    
169                    type = objectInput.readInt();
170                    extraInfo = objectInput.readUTF();
171                    expirationDate = objectInput.readLong();
172            }
173    
174            @Override
175            public void writeExternal(ObjectOutput objectOutput)
176                    throws IOException {
177                    objectOutput.writeLong(mvccVersion);
178    
179                    objectOutput.writeLong(ticketId);
180    
181                    objectOutput.writeLong(companyId);
182                    objectOutput.writeLong(createDate);
183    
184                    objectOutput.writeLong(classNameId);
185    
186                    objectOutput.writeLong(classPK);
187    
188                    if (key == null) {
189                            objectOutput.writeUTF(StringPool.BLANK);
190                    }
191                    else {
192                            objectOutput.writeUTF(key);
193                    }
194    
195                    objectOutput.writeInt(type);
196    
197                    if (extraInfo == null) {
198                            objectOutput.writeUTF(StringPool.BLANK);
199                    }
200                    else {
201                            objectOutput.writeUTF(extraInfo);
202                    }
203    
204                    objectOutput.writeLong(expirationDate);
205            }
206    
207            public long mvccVersion;
208            public long ticketId;
209            public long companyId;
210            public long createDate;
211            public long classNameId;
212            public long classPK;
213            public String key;
214            public int type;
215            public String extraInfo;
216            public long expirationDate;
217    }