001    /**
002     * Copyright (c) 2000-2012 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            public TrashEntry toEntityModel() {
069                    TrashEntryImpl trashEntryImpl = new TrashEntryImpl();
070    
071                    trashEntryImpl.setEntryId(entryId);
072                    trashEntryImpl.setGroupId(groupId);
073                    trashEntryImpl.setCompanyId(companyId);
074                    trashEntryImpl.setUserId(userId);
075    
076                    if (userName == null) {
077                            trashEntryImpl.setUserName(StringPool.BLANK);
078                    }
079                    else {
080                            trashEntryImpl.setUserName(userName);
081                    }
082    
083                    if (createDate == Long.MIN_VALUE) {
084                            trashEntryImpl.setCreateDate(null);
085                    }
086                    else {
087                            trashEntryImpl.setCreateDate(new Date(createDate));
088                    }
089    
090                    trashEntryImpl.setClassNameId(classNameId);
091                    trashEntryImpl.setClassPK(classPK);
092    
093                    if (typeSettings == null) {
094                            trashEntryImpl.setTypeSettings(StringPool.BLANK);
095                    }
096                    else {
097                            trashEntryImpl.setTypeSettings(typeSettings);
098                    }
099    
100                    trashEntryImpl.setStatus(status);
101    
102                    trashEntryImpl.resetOriginalValues();
103    
104                    return trashEntryImpl;
105            }
106    
107            public void readExternal(ObjectInput objectInput) throws IOException {
108                    entryId = objectInput.readLong();
109                    groupId = objectInput.readLong();
110                    companyId = objectInput.readLong();
111                    userId = objectInput.readLong();
112                    userName = objectInput.readUTF();
113                    createDate = objectInput.readLong();
114                    classNameId = objectInput.readLong();
115                    classPK = objectInput.readLong();
116                    typeSettings = objectInput.readUTF();
117                    status = objectInput.readInt();
118            }
119    
120            public void writeExternal(ObjectOutput objectOutput)
121                    throws IOException {
122                    objectOutput.writeLong(entryId);
123                    objectOutput.writeLong(groupId);
124                    objectOutput.writeLong(companyId);
125                    objectOutput.writeLong(userId);
126    
127                    if (userName == null) {
128                            objectOutput.writeUTF(StringPool.BLANK);
129                    }
130                    else {
131                            objectOutput.writeUTF(userName);
132                    }
133    
134                    objectOutput.writeLong(createDate);
135                    objectOutput.writeLong(classNameId);
136                    objectOutput.writeLong(classPK);
137    
138                    if (typeSettings == null) {
139                            objectOutput.writeUTF(StringPool.BLANK);
140                    }
141                    else {
142                            objectOutput.writeUTF(typeSettings);
143                    }
144    
145                    objectOutput.writeInt(status);
146            }
147    
148            public long entryId;
149            public long groupId;
150            public long companyId;
151            public long userId;
152            public String userName;
153            public long createDate;
154            public long classNameId;
155            public long classPK;
156            public String typeSettings;
157            public int status;
158    }