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