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.portal.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    import com.liferay.portal.model.MVCCModel;
024    import com.liferay.portal.model.Portlet;
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 Portlet in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see Portlet
036     * @generated
037     */
038    @ProviderType
039    public class PortletCacheModel implements CacheModel<Portlet>, Externalizable,
040            MVCCModel {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof PortletCacheModel)) {
048                            return false;
049                    }
050    
051                    PortletCacheModel portletCacheModel = (PortletCacheModel)obj;
052    
053                    if ((id == portletCacheModel.id) &&
054                                    (mvccVersion == portletCacheModel.mvccVersion)) {
055                            return true;
056                    }
057    
058                    return false;
059            }
060    
061            @Override
062            public int hashCode() {
063                    int hashCode = HashUtil.hash(0, id);
064    
065                    return HashUtil.hash(hashCode, mvccVersion);
066            }
067    
068            @Override
069            public long getMvccVersion() {
070                    return mvccVersion;
071            }
072    
073            @Override
074            public void setMvccVersion(long mvccVersion) {
075                    this.mvccVersion = mvccVersion;
076            }
077    
078            @Override
079            public String toString() {
080                    StringBundler sb = new StringBundler(13);
081    
082                    sb.append("{mvccVersion=");
083                    sb.append(mvccVersion);
084                    sb.append(", id=");
085                    sb.append(id);
086                    sb.append(", companyId=");
087                    sb.append(companyId);
088                    sb.append(", portletId=");
089                    sb.append(portletId);
090                    sb.append(", roles=");
091                    sb.append(roles);
092                    sb.append(", active=");
093                    sb.append(active);
094                    sb.append("}");
095    
096                    return sb.toString();
097            }
098    
099            @Override
100            public Portlet toEntityModel() {
101                    PortletImpl portletImpl = new PortletImpl();
102    
103                    portletImpl.setMvccVersion(mvccVersion);
104                    portletImpl.setId(id);
105                    portletImpl.setCompanyId(companyId);
106    
107                    if (portletId == null) {
108                            portletImpl.setPortletId(StringPool.BLANK);
109                    }
110                    else {
111                            portletImpl.setPortletId(portletId);
112                    }
113    
114                    if (roles == null) {
115                            portletImpl.setRoles(StringPool.BLANK);
116                    }
117                    else {
118                            portletImpl.setRoles(roles);
119                    }
120    
121                    portletImpl.setActive(active);
122    
123                    portletImpl.resetOriginalValues();
124    
125                    return portletImpl;
126            }
127    
128            @Override
129            public void readExternal(ObjectInput objectInput) throws IOException {
130                    mvccVersion = objectInput.readLong();
131                    id = objectInput.readLong();
132                    companyId = objectInput.readLong();
133                    portletId = objectInput.readUTF();
134                    roles = objectInput.readUTF();
135                    active = objectInput.readBoolean();
136            }
137    
138            @Override
139            public void writeExternal(ObjectOutput objectOutput)
140                    throws IOException {
141                    objectOutput.writeLong(mvccVersion);
142                    objectOutput.writeLong(id);
143                    objectOutput.writeLong(companyId);
144    
145                    if (portletId == null) {
146                            objectOutput.writeUTF(StringPool.BLANK);
147                    }
148                    else {
149                            objectOutput.writeUTF(portletId);
150                    }
151    
152                    if (roles == null) {
153                            objectOutput.writeUTF(StringPool.BLANK);
154                    }
155                    else {
156                            objectOutput.writeUTF(roles);
157                    }
158    
159                    objectOutput.writeBoolean(active);
160            }
161    
162            public long mvccVersion;
163            public long id;
164            public long companyId;
165            public String portletId;
166            public String roles;
167            public boolean active;
168    }