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.wiki.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.wiki.model.WikiPageResource;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    /**
029     * The cache model class for representing WikiPageResource in entity cache.
030     *
031     * @author Brian Wing Shun Chan
032     * @see WikiPageResource
033     * @generated
034     */
035    public class WikiPageResourceCacheModel implements CacheModel<WikiPageResource>,
036            Externalizable {
037            @Override
038            public String toString() {
039                    StringBundler sb = new StringBundler(9);
040    
041                    sb.append("{uuid=");
042                    sb.append(uuid);
043                    sb.append(", resourcePrimKey=");
044                    sb.append(resourcePrimKey);
045                    sb.append(", nodeId=");
046                    sb.append(nodeId);
047                    sb.append(", title=");
048                    sb.append(title);
049                    sb.append("}");
050    
051                    return sb.toString();
052            }
053    
054            @Override
055            public WikiPageResource toEntityModel() {
056                    WikiPageResourceImpl wikiPageResourceImpl = new WikiPageResourceImpl();
057    
058                    if (uuid == null) {
059                            wikiPageResourceImpl.setUuid(StringPool.BLANK);
060                    }
061                    else {
062                            wikiPageResourceImpl.setUuid(uuid);
063                    }
064    
065                    wikiPageResourceImpl.setResourcePrimKey(resourcePrimKey);
066                    wikiPageResourceImpl.setNodeId(nodeId);
067    
068                    if (title == null) {
069                            wikiPageResourceImpl.setTitle(StringPool.BLANK);
070                    }
071                    else {
072                            wikiPageResourceImpl.setTitle(title);
073                    }
074    
075                    wikiPageResourceImpl.resetOriginalValues();
076    
077                    return wikiPageResourceImpl;
078            }
079    
080            @Override
081            public void readExternal(ObjectInput objectInput) throws IOException {
082                    uuid = objectInput.readUTF();
083                    resourcePrimKey = objectInput.readLong();
084                    nodeId = objectInput.readLong();
085                    title = objectInput.readUTF();
086            }
087    
088            @Override
089            public void writeExternal(ObjectOutput objectOutput)
090                    throws IOException {
091                    if (uuid == null) {
092                            objectOutput.writeUTF(StringPool.BLANK);
093                    }
094                    else {
095                            objectOutput.writeUTF(uuid);
096                    }
097    
098                    objectOutput.writeLong(resourcePrimKey);
099                    objectOutput.writeLong(nodeId);
100    
101                    if (title == null) {
102                            objectOutput.writeUTF(StringPool.BLANK);
103                    }
104                    else {
105                            objectOutput.writeUTF(title);
106                    }
107            }
108    
109            public String uuid;
110            public long resourcePrimKey;
111            public long nodeId;
112            public String title;
113    }