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