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.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(25);
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(", name=");
064                    sb.append(name);
065                    sb.append(", description=");
066                    sb.append(description);
067                    sb.append("}");
068    
069                    return sb.toString();
070            }
071    
072            public BookmarksFolder toEntityModel() {
073                    BookmarksFolderImpl bookmarksFolderImpl = new BookmarksFolderImpl();
074    
075                    if (uuid == null) {
076                            bookmarksFolderImpl.setUuid(StringPool.BLANK);
077                    }
078                    else {
079                            bookmarksFolderImpl.setUuid(uuid);
080                    }
081    
082                    bookmarksFolderImpl.setFolderId(folderId);
083                    bookmarksFolderImpl.setGroupId(groupId);
084                    bookmarksFolderImpl.setCompanyId(companyId);
085                    bookmarksFolderImpl.setUserId(userId);
086    
087                    if (userName == null) {
088                            bookmarksFolderImpl.setUserName(StringPool.BLANK);
089                    }
090                    else {
091                            bookmarksFolderImpl.setUserName(userName);
092                    }
093    
094                    if (createDate == Long.MIN_VALUE) {
095                            bookmarksFolderImpl.setCreateDate(null);
096                    }
097                    else {
098                            bookmarksFolderImpl.setCreateDate(new Date(createDate));
099                    }
100    
101                    if (modifiedDate == Long.MIN_VALUE) {
102                            bookmarksFolderImpl.setModifiedDate(null);
103                    }
104                    else {
105                            bookmarksFolderImpl.setModifiedDate(new Date(modifiedDate));
106                    }
107    
108                    bookmarksFolderImpl.setResourceBlockId(resourceBlockId);
109                    bookmarksFolderImpl.setParentFolderId(parentFolderId);
110    
111                    if (name == null) {
112                            bookmarksFolderImpl.setName(StringPool.BLANK);
113                    }
114                    else {
115                            bookmarksFolderImpl.setName(name);
116                    }
117    
118                    if (description == null) {
119                            bookmarksFolderImpl.setDescription(StringPool.BLANK);
120                    }
121                    else {
122                            bookmarksFolderImpl.setDescription(description);
123                    }
124    
125                    bookmarksFolderImpl.resetOriginalValues();
126    
127                    return bookmarksFolderImpl;
128            }
129    
130            public void readExternal(ObjectInput objectInput) throws IOException {
131                    uuid = objectInput.readUTF();
132                    folderId = objectInput.readLong();
133                    groupId = objectInput.readLong();
134                    companyId = objectInput.readLong();
135                    userId = objectInput.readLong();
136                    userName = objectInput.readUTF();
137                    createDate = objectInput.readLong();
138                    modifiedDate = objectInput.readLong();
139                    resourceBlockId = objectInput.readLong();
140                    parentFolderId = objectInput.readLong();
141                    name = objectInput.readUTF();
142                    description = objectInput.readUTF();
143            }
144    
145            public void writeExternal(ObjectOutput objectOutput)
146                    throws IOException {
147                    if (uuid == null) {
148                            objectOutput.writeUTF(StringPool.BLANK);
149                    }
150                    else {
151                            objectOutput.writeUTF(uuid);
152                    }
153    
154                    objectOutput.writeLong(folderId);
155                    objectOutput.writeLong(groupId);
156                    objectOutput.writeLong(companyId);
157                    objectOutput.writeLong(userId);
158    
159                    if (userName == null) {
160                            objectOutput.writeUTF(StringPool.BLANK);
161                    }
162                    else {
163                            objectOutput.writeUTF(userName);
164                    }
165    
166                    objectOutput.writeLong(createDate);
167                    objectOutput.writeLong(modifiedDate);
168                    objectOutput.writeLong(resourceBlockId);
169                    objectOutput.writeLong(parentFolderId);
170    
171                    if (name == null) {
172                            objectOutput.writeUTF(StringPool.BLANK);
173                    }
174                    else {
175                            objectOutput.writeUTF(name);
176                    }
177    
178                    if (description == null) {
179                            objectOutput.writeUTF(StringPool.BLANK);
180                    }
181                    else {
182                            objectOutput.writeUTF(description);
183                    }
184            }
185    
186            public String uuid;
187            public long folderId;
188            public long groupId;
189            public long companyId;
190            public long userId;
191            public String userName;
192            public long createDate;
193            public long modifiedDate;
194            public long resourceBlockId;
195            public long parentFolderId;
196            public String name;
197            public String description;
198    }