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.journal.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.journal.model.JournalArticleResource;
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 JournalArticleResource in entity cache.
030     *
031     * @author Brian Wing Shun Chan
032     * @see JournalArticleResource
033     * @generated
034     */
035    public class JournalArticleResourceCacheModel implements CacheModel<JournalArticleResource>,
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(", groupId=");
046                    sb.append(groupId);
047                    sb.append(", articleId=");
048                    sb.append(articleId);
049                    sb.append("}");
050    
051                    return sb.toString();
052            }
053    
054            @Override
055            public JournalArticleResource toEntityModel() {
056                    JournalArticleResourceImpl journalArticleResourceImpl = new JournalArticleResourceImpl();
057    
058                    if (uuid == null) {
059                            journalArticleResourceImpl.setUuid(StringPool.BLANK);
060                    }
061                    else {
062                            journalArticleResourceImpl.setUuid(uuid);
063                    }
064    
065                    journalArticleResourceImpl.setResourcePrimKey(resourcePrimKey);
066                    journalArticleResourceImpl.setGroupId(groupId);
067    
068                    if (articleId == null) {
069                            journalArticleResourceImpl.setArticleId(StringPool.BLANK);
070                    }
071                    else {
072                            journalArticleResourceImpl.setArticleId(articleId);
073                    }
074    
075                    journalArticleResourceImpl.resetOriginalValues();
076    
077                    return journalArticleResourceImpl;
078            }
079    
080            @Override
081            public void readExternal(ObjectInput objectInput) throws IOException {
082                    uuid = objectInput.readUTF();
083                    resourcePrimKey = objectInput.readLong();
084                    groupId = objectInput.readLong();
085                    articleId = 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(groupId);
100    
101                    if (articleId == null) {
102                            objectOutput.writeUTF(StringPool.BLANK);
103                    }
104                    else {
105                            objectOutput.writeUTF(articleId);
106                    }
107            }
108    
109            public String uuid;
110            public long resourcePrimKey;
111            public long groupId;
112            public String articleId;
113    }