001    /**
002     * Copyright (c) 2000-2013 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 com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    import com.liferay.portal.model.Ticket;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    import java.util.Date;
028    
029    /**
030     * The cache model class for representing Ticket in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see Ticket
034     * @generated
035     */
036    public class TicketCacheModel implements CacheModel<Ticket>, Externalizable {
037            @Override
038            public String toString() {
039                    StringBundler sb = new StringBundler(19);
040    
041                    sb.append("{ticketId=");
042                    sb.append(ticketId);
043                    sb.append(", companyId=");
044                    sb.append(companyId);
045                    sb.append(", createDate=");
046                    sb.append(createDate);
047                    sb.append(", classNameId=");
048                    sb.append(classNameId);
049                    sb.append(", classPK=");
050                    sb.append(classPK);
051                    sb.append(", key=");
052                    sb.append(key);
053                    sb.append(", type=");
054                    sb.append(type);
055                    sb.append(", extraInfo=");
056                    sb.append(extraInfo);
057                    sb.append(", expirationDate=");
058                    sb.append(expirationDate);
059                    sb.append("}");
060    
061                    return sb.toString();
062            }
063    
064            @Override
065            public Ticket toEntityModel() {
066                    TicketImpl ticketImpl = new TicketImpl();
067    
068                    ticketImpl.setTicketId(ticketId);
069                    ticketImpl.setCompanyId(companyId);
070    
071                    if (createDate == Long.MIN_VALUE) {
072                            ticketImpl.setCreateDate(null);
073                    }
074                    else {
075                            ticketImpl.setCreateDate(new Date(createDate));
076                    }
077    
078                    ticketImpl.setClassNameId(classNameId);
079                    ticketImpl.setClassPK(classPK);
080    
081                    if (key == null) {
082                            ticketImpl.setKey(StringPool.BLANK);
083                    }
084                    else {
085                            ticketImpl.setKey(key);
086                    }
087    
088                    ticketImpl.setType(type);
089    
090                    if (extraInfo == null) {
091                            ticketImpl.setExtraInfo(StringPool.BLANK);
092                    }
093                    else {
094                            ticketImpl.setExtraInfo(extraInfo);
095                    }
096    
097                    if (expirationDate == Long.MIN_VALUE) {
098                            ticketImpl.setExpirationDate(null);
099                    }
100                    else {
101                            ticketImpl.setExpirationDate(new Date(expirationDate));
102                    }
103    
104                    ticketImpl.resetOriginalValues();
105    
106                    return ticketImpl;
107            }
108    
109            @Override
110            public void readExternal(ObjectInput objectInput) throws IOException {
111                    ticketId = objectInput.readLong();
112                    companyId = objectInput.readLong();
113                    createDate = objectInput.readLong();
114                    classNameId = objectInput.readLong();
115                    classPK = objectInput.readLong();
116                    key = objectInput.readUTF();
117                    type = objectInput.readInt();
118                    extraInfo = objectInput.readUTF();
119                    expirationDate = objectInput.readLong();
120            }
121    
122            @Override
123            public void writeExternal(ObjectOutput objectOutput)
124                    throws IOException {
125                    objectOutput.writeLong(ticketId);
126                    objectOutput.writeLong(companyId);
127                    objectOutput.writeLong(createDate);
128                    objectOutput.writeLong(classNameId);
129                    objectOutput.writeLong(classPK);
130    
131                    if (key == null) {
132                            objectOutput.writeUTF(StringPool.BLANK);
133                    }
134                    else {
135                            objectOutput.writeUTF(key);
136                    }
137    
138                    objectOutput.writeInt(type);
139    
140                    if (extraInfo == null) {
141                            objectOutput.writeUTF(StringPool.BLANK);
142                    }
143                    else {
144                            objectOutput.writeUTF(extraInfo);
145                    }
146    
147                    objectOutput.writeLong(expirationDate);
148            }
149    
150            public long ticketId;
151            public long companyId;
152            public long createDate;
153            public long classNameId;
154            public long classPK;
155            public String key;
156            public int type;
157            public String extraInfo;
158            public long expirationDate;
159    }