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