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.BookmarksEntry;
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 BookmarksEntry in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see BookmarksEntry
035     * @generated
036     */
037    public class BookmarksEntryCacheModel implements CacheModel<BookmarksEntry>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(31);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", entryId=");
046                    sb.append(entryId);
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(", folderId=");
062                    sb.append(folderId);
063                    sb.append(", name=");
064                    sb.append(name);
065                    sb.append(", url=");
066                    sb.append(url);
067                    sb.append(", description=");
068                    sb.append(description);
069                    sb.append(", visits=");
070                    sb.append(visits);
071                    sb.append(", priority=");
072                    sb.append(priority);
073                    sb.append("}");
074    
075                    return sb.toString();
076            }
077    
078            public BookmarksEntry toEntityModel() {
079                    BookmarksEntryImpl bookmarksEntryImpl = new BookmarksEntryImpl();
080    
081                    if (uuid == null) {
082                            bookmarksEntryImpl.setUuid(StringPool.BLANK);
083                    }
084                    else {
085                            bookmarksEntryImpl.setUuid(uuid);
086                    }
087    
088                    bookmarksEntryImpl.setEntryId(entryId);
089                    bookmarksEntryImpl.setGroupId(groupId);
090                    bookmarksEntryImpl.setCompanyId(companyId);
091                    bookmarksEntryImpl.setUserId(userId);
092    
093                    if (userName == null) {
094                            bookmarksEntryImpl.setUserName(StringPool.BLANK);
095                    }
096                    else {
097                            bookmarksEntryImpl.setUserName(userName);
098                    }
099    
100                    if (createDate == Long.MIN_VALUE) {
101                            bookmarksEntryImpl.setCreateDate(null);
102                    }
103                    else {
104                            bookmarksEntryImpl.setCreateDate(new Date(createDate));
105                    }
106    
107                    if (modifiedDate == Long.MIN_VALUE) {
108                            bookmarksEntryImpl.setModifiedDate(null);
109                    }
110                    else {
111                            bookmarksEntryImpl.setModifiedDate(new Date(modifiedDate));
112                    }
113    
114                    bookmarksEntryImpl.setResourceBlockId(resourceBlockId);
115                    bookmarksEntryImpl.setFolderId(folderId);
116    
117                    if (name == null) {
118                            bookmarksEntryImpl.setName(StringPool.BLANK);
119                    }
120                    else {
121                            bookmarksEntryImpl.setName(name);
122                    }
123    
124                    if (url == null) {
125                            bookmarksEntryImpl.setUrl(StringPool.BLANK);
126                    }
127                    else {
128                            bookmarksEntryImpl.setUrl(url);
129                    }
130    
131                    if (description == null) {
132                            bookmarksEntryImpl.setDescription(StringPool.BLANK);
133                    }
134                    else {
135                            bookmarksEntryImpl.setDescription(description);
136                    }
137    
138                    bookmarksEntryImpl.setVisits(visits);
139                    bookmarksEntryImpl.setPriority(priority);
140    
141                    bookmarksEntryImpl.resetOriginalValues();
142    
143                    return bookmarksEntryImpl;
144            }
145    
146            public void readExternal(ObjectInput objectInput) throws IOException {
147                    uuid = objectInput.readUTF();
148                    entryId = objectInput.readLong();
149                    groupId = objectInput.readLong();
150                    companyId = objectInput.readLong();
151                    userId = objectInput.readLong();
152                    userName = objectInput.readUTF();
153                    createDate = objectInput.readLong();
154                    modifiedDate = objectInput.readLong();
155                    resourceBlockId = objectInput.readLong();
156                    folderId = objectInput.readLong();
157                    name = objectInput.readUTF();
158                    url = objectInput.readUTF();
159                    description = objectInput.readUTF();
160                    visits = objectInput.readInt();
161                    priority = objectInput.readInt();
162            }
163    
164            public void writeExternal(ObjectOutput objectOutput)
165                    throws IOException {
166                    if (uuid == null) {
167                            objectOutput.writeUTF(StringPool.BLANK);
168                    }
169                    else {
170                            objectOutput.writeUTF(uuid);
171                    }
172    
173                    objectOutput.writeLong(entryId);
174                    objectOutput.writeLong(groupId);
175                    objectOutput.writeLong(companyId);
176                    objectOutput.writeLong(userId);
177    
178                    if (userName == null) {
179                            objectOutput.writeUTF(StringPool.BLANK);
180                    }
181                    else {
182                            objectOutput.writeUTF(userName);
183                    }
184    
185                    objectOutput.writeLong(createDate);
186                    objectOutput.writeLong(modifiedDate);
187                    objectOutput.writeLong(resourceBlockId);
188                    objectOutput.writeLong(folderId);
189    
190                    if (name == null) {
191                            objectOutput.writeUTF(StringPool.BLANK);
192                    }
193                    else {
194                            objectOutput.writeUTF(name);
195                    }
196    
197                    if (url == null) {
198                            objectOutput.writeUTF(StringPool.BLANK);
199                    }
200                    else {
201                            objectOutput.writeUTF(url);
202                    }
203    
204                    if (description == null) {
205                            objectOutput.writeUTF(StringPool.BLANK);
206                    }
207                    else {
208                            objectOutput.writeUTF(description);
209                    }
210    
211                    objectOutput.writeInt(visits);
212                    objectOutput.writeInt(priority);
213            }
214    
215            public String uuid;
216            public long entryId;
217            public long groupId;
218            public long companyId;
219            public long userId;
220            public String userName;
221            public long createDate;
222            public long modifiedDate;
223            public long resourceBlockId;
224            public long folderId;
225            public String name;
226            public String url;
227            public String description;
228            public int visits;
229            public int priority;
230    }