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.journal.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.util.HashUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.CacheModel;
023    
024    import com.liferay.portlet.journal.model.JournalArticleResource;
025    
026    import java.io.Externalizable;
027    import java.io.IOException;
028    import java.io.ObjectInput;
029    import java.io.ObjectOutput;
030    
031    /**
032     * The cache model class for representing JournalArticleResource in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see JournalArticleResource
036     * @generated
037     */
038    @ProviderType
039    public class JournalArticleResourceCacheModel implements CacheModel<JournalArticleResource>,
040            Externalizable {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof JournalArticleResourceCacheModel)) {
048                            return false;
049                    }
050    
051                    JournalArticleResourceCacheModel journalArticleResourceCacheModel = (JournalArticleResourceCacheModel)obj;
052    
053                    if (resourcePrimKey == journalArticleResourceCacheModel.resourcePrimKey) {
054                            return true;
055                    }
056    
057                    return false;
058            }
059    
060            @Override
061            public int hashCode() {
062                    return HashUtil.hash(0, resourcePrimKey);
063            }
064    
065            @Override
066            public String toString() {
067                    StringBundler sb = new StringBundler(9);
068    
069                    sb.append("{uuid=");
070                    sb.append(uuid);
071                    sb.append(", resourcePrimKey=");
072                    sb.append(resourcePrimKey);
073                    sb.append(", groupId=");
074                    sb.append(groupId);
075                    sb.append(", articleId=");
076                    sb.append(articleId);
077                    sb.append("}");
078    
079                    return sb.toString();
080            }
081    
082            @Override
083            public JournalArticleResource toEntityModel() {
084                    JournalArticleResourceImpl journalArticleResourceImpl = new JournalArticleResourceImpl();
085    
086                    if (uuid == null) {
087                            journalArticleResourceImpl.setUuid(StringPool.BLANK);
088                    }
089                    else {
090                            journalArticleResourceImpl.setUuid(uuid);
091                    }
092    
093                    journalArticleResourceImpl.setResourcePrimKey(resourcePrimKey);
094                    journalArticleResourceImpl.setGroupId(groupId);
095    
096                    if (articleId == null) {
097                            journalArticleResourceImpl.setArticleId(StringPool.BLANK);
098                    }
099                    else {
100                            journalArticleResourceImpl.setArticleId(articleId);
101                    }
102    
103                    journalArticleResourceImpl.resetOriginalValues();
104    
105                    return journalArticleResourceImpl;
106            }
107    
108            @Override
109            public void readExternal(ObjectInput objectInput) throws IOException {
110                    uuid = objectInput.readUTF();
111                    resourcePrimKey = objectInput.readLong();
112                    groupId = objectInput.readLong();
113                    articleId = objectInput.readUTF();
114            }
115    
116            @Override
117            public void writeExternal(ObjectOutput objectOutput)
118                    throws IOException {
119                    if (uuid == null) {
120                            objectOutput.writeUTF(StringPool.BLANK);
121                    }
122                    else {
123                            objectOutput.writeUTF(uuid);
124                    }
125    
126                    objectOutput.writeLong(resourcePrimKey);
127                    objectOutput.writeLong(groupId);
128    
129                    if (articleId == null) {
130                            objectOutput.writeUTF(StringPool.BLANK);
131                    }
132                    else {
133                            objectOutput.writeUTF(articleId);
134                    }
135            }
136    
137            public String uuid;
138            public long resourcePrimKey;
139            public long groupId;
140            public String articleId;
141    }