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.ResourcePermission;
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 ResourcePermission in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see ResourcePermission
036     * @generated
037     */
038    @ProviderType
039    public class ResourcePermissionCacheModel implements CacheModel<ResourcePermission>,
040            Externalizable, MVCCModel {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof ResourcePermissionCacheModel)) {
048                            return false;
049                    }
050    
051                    ResourcePermissionCacheModel resourcePermissionCacheModel = (ResourcePermissionCacheModel)obj;
052    
053                    if ((resourcePermissionId == resourcePermissionCacheModel.resourcePermissionId) &&
054                                    (mvccVersion == resourcePermissionCacheModel.mvccVersion)) {
055                            return true;
056                    }
057    
058                    return false;
059            }
060    
061            @Override
062            public int hashCode() {
063                    int hashCode = HashUtil.hash(0, resourcePermissionId);
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(19);
081    
082                    sb.append("{mvccVersion=");
083                    sb.append(mvccVersion);
084                    sb.append(", resourcePermissionId=");
085                    sb.append(resourcePermissionId);
086                    sb.append(", companyId=");
087                    sb.append(companyId);
088                    sb.append(", name=");
089                    sb.append(name);
090                    sb.append(", scope=");
091                    sb.append(scope);
092                    sb.append(", primKey=");
093                    sb.append(primKey);
094                    sb.append(", roleId=");
095                    sb.append(roleId);
096                    sb.append(", ownerId=");
097                    sb.append(ownerId);
098                    sb.append(", actionIds=");
099                    sb.append(actionIds);
100                    sb.append("}");
101    
102                    return sb.toString();
103            }
104    
105            @Override
106            public ResourcePermission toEntityModel() {
107                    ResourcePermissionImpl resourcePermissionImpl = new ResourcePermissionImpl();
108    
109                    resourcePermissionImpl.setMvccVersion(mvccVersion);
110                    resourcePermissionImpl.setResourcePermissionId(resourcePermissionId);
111                    resourcePermissionImpl.setCompanyId(companyId);
112    
113                    if (name == null) {
114                            resourcePermissionImpl.setName(StringPool.BLANK);
115                    }
116                    else {
117                            resourcePermissionImpl.setName(name);
118                    }
119    
120                    resourcePermissionImpl.setScope(scope);
121    
122                    if (primKey == null) {
123                            resourcePermissionImpl.setPrimKey(StringPool.BLANK);
124                    }
125                    else {
126                            resourcePermissionImpl.setPrimKey(primKey);
127                    }
128    
129                    resourcePermissionImpl.setRoleId(roleId);
130                    resourcePermissionImpl.setOwnerId(ownerId);
131                    resourcePermissionImpl.setActionIds(actionIds);
132    
133                    resourcePermissionImpl.resetOriginalValues();
134    
135                    return resourcePermissionImpl;
136            }
137    
138            @Override
139            public void readExternal(ObjectInput objectInput) throws IOException {
140                    mvccVersion = objectInput.readLong();
141                    resourcePermissionId = objectInput.readLong();
142                    companyId = objectInput.readLong();
143                    name = objectInput.readUTF();
144                    scope = objectInput.readInt();
145                    primKey = objectInput.readUTF();
146                    roleId = objectInput.readLong();
147                    ownerId = objectInput.readLong();
148                    actionIds = objectInput.readLong();
149            }
150    
151            @Override
152            public void writeExternal(ObjectOutput objectOutput)
153                    throws IOException {
154                    objectOutput.writeLong(mvccVersion);
155                    objectOutput.writeLong(resourcePermissionId);
156                    objectOutput.writeLong(companyId);
157    
158                    if (name == null) {
159                            objectOutput.writeUTF(StringPool.BLANK);
160                    }
161                    else {
162                            objectOutput.writeUTF(name);
163                    }
164    
165                    objectOutput.writeInt(scope);
166    
167                    if (primKey == null) {
168                            objectOutput.writeUTF(StringPool.BLANK);
169                    }
170                    else {
171                            objectOutput.writeUTF(primKey);
172                    }
173    
174                    objectOutput.writeLong(roleId);
175                    objectOutput.writeLong(ownerId);
176                    objectOutput.writeLong(actionIds);
177            }
178    
179            public long mvccVersion;
180            public long resourcePermissionId;
181            public long companyId;
182            public String name;
183            public int scope;
184            public String primKey;
185            public long roleId;
186            public long ownerId;
187            public long actionIds;
188    }