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.bookmarks.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.bookmarks.model.BookmarksFolder;
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 BookmarksFolder in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see BookmarksFolder
035     * @generated
036     */
037    public class BookmarksFolderCacheModel implements CacheModel<BookmarksFolder>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(35);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", folderId=");
046                    sb.append(folderId);
047                    sb.append(", groupId=");
048                    sb.append(groupId);
049                    sb.append(", companyId=");
050                    sb.append(companyId);
051                    sb.append(", userId=");
052                    sb.append(userId);
053                    sb.append(", userName=");
054                    sb.append(userName);
055                    sb.append(", createDate=");
056                    sb.append(createDate);
057                    sb.append(", modifiedDate=");
058                    sb.append(modifiedDate);
059                    sb.append(", resourceBlockId=");
060                    sb.append(resourceBlockId);
061                    sb.append(", parentFolderId=");
062                    sb.append(parentFolderId);
063                    sb.append(", treePath=");
064                    sb.append(treePath);
065                    sb.append(", name=");
066                    sb.append(name);
067                    sb.append(", description=");
068                    sb.append(description);
069                    sb.append(", status=");
070                    sb.append(status);
071                    sb.append(", statusByUserId=");
072                    sb.append(statusByUserId);
073                    sb.append(", statusByUserName=");
074                    sb.append(statusByUserName);
075                    sb.append(", statusDate=");
076                    sb.append(statusDate);
077                    sb.append("}");
078    
079                    return sb.toString();
080            }
081    
082            @Override
083            public BookmarksFolder toEntityModel() {
084                    BookmarksFolderImpl bookmarksFolderImpl = new BookmarksFolderImpl();
085    
086                    if (uuid == null) {
087                            bookmarksFolderImpl.setUuid(StringPool.BLANK);
088                    }
089                    else {
090                            bookmarksFolderImpl.setUuid(uuid);
091                    }
092    
093                    bookmarksFolderImpl.setFolderId(folderId);
094                    bookmarksFolderImpl.setGroupId(groupId);
095                    bookmarksFolderImpl.setCompanyId(companyId);
096                    bookmarksFolderImpl.setUserId(userId);
097    
098                    if (userName == null) {
099                            bookmarksFolderImpl.setUserName(StringPool.BLANK);
100                    }
101                    else {
102                            bookmarksFolderImpl.setUserName(userName);
103                    }
104    
105                    if (createDate == Long.MIN_VALUE) {
106                            bookmarksFolderImpl.setCreateDate(null);
107                    }
108                    else {
109                            bookmarksFolderImpl.setCreateDate(new Date(createDate));
110                    }
111    
112                    if (modifiedDate == Long.MIN_VALUE) {
113                            bookmarksFolderImpl.setModifiedDate(null);
114                    }
115                    else {
116                            bookmarksFolderImpl.setModifiedDate(new Date(modifiedDate));
117                    }
118    
119                    bookmarksFolderImpl.setResourceBlockId(resourceBlockId);
120                    bookmarksFolderImpl.setParentFolderId(parentFolderId);
121    
122                    if (treePath == null) {
123                            bookmarksFolderImpl.setTreePath(StringPool.BLANK);
124                    }
125                    else {
126                            bookmarksFolderImpl.setTreePath(treePath);
127                    }
128    
129                    if (name == null) {
130                            bookmarksFolderImpl.setName(StringPool.BLANK);
131                    }
132                    else {
133                            bookmarksFolderImpl.setName(name);
134                    }
135    
136                    if (description == null) {
137                            bookmarksFolderImpl.setDescription(StringPool.BLANK);
138                    }
139                    else {
140                            bookmarksFolderImpl.setDescription(description);
141                    }
142    
143                    bookmarksFolderImpl.setStatus(status);
144                    bookmarksFolderImpl.setStatusByUserId(statusByUserId);
145    
146                    if (statusByUserName == null) {
147                            bookmarksFolderImpl.setStatusByUserName(StringPool.BLANK);
148                    }
149                    else {
150                            bookmarksFolderImpl.setStatusByUserName(statusByUserName);
151                    }
152    
153                    if (statusDate == Long.MIN_VALUE) {
154                            bookmarksFolderImpl.setStatusDate(null);
155                    }
156                    else {
157                            bookmarksFolderImpl.setStatusDate(new Date(statusDate));
158                    }
159    
160                    bookmarksFolderImpl.resetOriginalValues();
161    
162                    return bookmarksFolderImpl;
163            }
164    
165            @Override
166            public void readExternal(ObjectInput objectInput) throws IOException {
167                    uuid = objectInput.readUTF();
168                    folderId = objectInput.readLong();
169                    groupId = objectInput.readLong();
170                    companyId = objectInput.readLong();
171                    userId = objectInput.readLong();
172                    userName = objectInput.readUTF();
173                    createDate = objectInput.readLong();
174                    modifiedDate = objectInput.readLong();
175                    resourceBlockId = objectInput.readLong();
176                    parentFolderId = objectInput.readLong();
177                    treePath = objectInput.readUTF();
178                    name = objectInput.readUTF();
179                    description = objectInput.readUTF();
180                    status = objectInput.readInt();
181                    statusByUserId = objectInput.readLong();
182                    statusByUserName = objectInput.readUTF();
183                    statusDate = objectInput.readLong();
184            }
185    
186            @Override
187            public void writeExternal(ObjectOutput objectOutput)
188                    throws IOException {
189                    if (uuid == null) {
190                            objectOutput.writeUTF(StringPool.BLANK);
191                    }
192                    else {
193                            objectOutput.writeUTF(uuid);
194                    }
195    
196                    objectOutput.writeLong(folderId);
197                    objectOutput.writeLong(groupId);
198                    objectOutput.writeLong(companyId);
199                    objectOutput.writeLong(userId);
200    
201                    if (userName == null) {
202                            objectOutput.writeUTF(StringPool.BLANK);
203                    }
204                    else {
205                            objectOutput.writeUTF(userName);
206                    }
207    
208                    objectOutput.writeLong(createDate);
209                    objectOutput.writeLong(modifiedDate);
210                    objectOutput.writeLong(resourceBlockId);
211                    objectOutput.writeLong(parentFolderId);
212    
213                    if (treePath == null) {
214                            objectOutput.writeUTF(StringPool.BLANK);
215                    }
216                    else {
217                            objectOutput.writeUTF(treePath);
218                    }
219    
220                    if (name == null) {
221                            objectOutput.writeUTF(StringPool.BLANK);
222                    }
223                    else {
224                            objectOutput.writeUTF(name);
225                    }
226    
227                    if (description == null) {
228                            objectOutput.writeUTF(StringPool.BLANK);
229                    }
230                    else {
231                            objectOutput.writeUTF(description);
232                    }
233    
234                    objectOutput.writeInt(status);
235                    objectOutput.writeLong(statusByUserId);
236    
237                    if (statusByUserName == null) {
238                            objectOutput.writeUTF(StringPool.BLANK);
239                    }
240                    else {
241                            objectOutput.writeUTF(statusByUserName);
242                    }
243    
244                    objectOutput.writeLong(statusDate);
245            }
246    
247            public String uuid;
248            public long folderId;
249            public long groupId;
250            public long companyId;
251            public long userId;
252            public String userName;
253            public long createDate;
254            public long modifiedDate;
255            public long resourceBlockId;
256            public long parentFolderId;
257            public String treePath;
258            public String name;
259            public String description;
260            public int status;
261            public long statusByUserId;
262            public String statusByUserName;
263            public long statusDate;
264    }