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(23);
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(", primKeyId=");
095                    sb.append(primKeyId);
096                    sb.append(", roleId=");
097                    sb.append(roleId);
098                    sb.append(", ownerId=");
099                    sb.append(ownerId);
100                    sb.append(", actionIds=");
101                    sb.append(actionIds);
102                    sb.append(", viewActionId=");
103                    sb.append(viewActionId);
104                    sb.append("}");
105    
106                    return sb.toString();
107            }
108    
109            @Override
110            public ResourcePermission toEntityModel() {
111                    ResourcePermissionImpl resourcePermissionImpl = new ResourcePermissionImpl();
112    
113                    resourcePermissionImpl.setMvccVersion(mvccVersion);
114                    resourcePermissionImpl.setResourcePermissionId(resourcePermissionId);
115                    resourcePermissionImpl.setCompanyId(companyId);
116    
117                    if (name == null) {
118                            resourcePermissionImpl.setName(StringPool.BLANK);
119                    }
120                    else {
121                            resourcePermissionImpl.setName(name);
122                    }
123    
124                    resourcePermissionImpl.setScope(scope);
125    
126                    if (primKey == null) {
127                            resourcePermissionImpl.setPrimKey(StringPool.BLANK);
128                    }
129                    else {
130                            resourcePermissionImpl.setPrimKey(primKey);
131                    }
132    
133                    resourcePermissionImpl.setPrimKeyId(primKeyId);
134                    resourcePermissionImpl.setRoleId(roleId);
135                    resourcePermissionImpl.setOwnerId(ownerId);
136                    resourcePermissionImpl.setActionIds(actionIds);
137                    resourcePermissionImpl.setViewActionId(viewActionId);
138    
139                    resourcePermissionImpl.resetOriginalValues();
140    
141                    return resourcePermissionImpl;
142            }
143    
144            @Override
145            public void readExternal(ObjectInput objectInput) throws IOException {
146                    mvccVersion = objectInput.readLong();
147                    resourcePermissionId = objectInput.readLong();
148                    companyId = objectInput.readLong();
149                    name = objectInput.readUTF();
150                    scope = objectInput.readInt();
151                    primKey = objectInput.readUTF();
152                    primKeyId = objectInput.readLong();
153                    roleId = objectInput.readLong();
154                    ownerId = objectInput.readLong();
155                    actionIds = objectInput.readLong();
156                    viewActionId = objectInput.readBoolean();
157            }
158    
159            @Override
160            public void writeExternal(ObjectOutput objectOutput)
161                    throws IOException {
162                    objectOutput.writeLong(mvccVersion);
163                    objectOutput.writeLong(resourcePermissionId);
164                    objectOutput.writeLong(companyId);
165    
166                    if (name == null) {
167                            objectOutput.writeUTF(StringPool.BLANK);
168                    }
169                    else {
170                            objectOutput.writeUTF(name);
171                    }
172    
173                    objectOutput.writeInt(scope);
174    
175                    if (primKey == null) {
176                            objectOutput.writeUTF(StringPool.BLANK);
177                    }
178                    else {
179                            objectOutput.writeUTF(primKey);
180                    }
181    
182                    objectOutput.writeLong(primKeyId);
183                    objectOutput.writeLong(roleId);
184                    objectOutput.writeLong(ownerId);
185                    objectOutput.writeLong(actionIds);
186                    objectOutput.writeBoolean(viewActionId);
187            }
188    
189            public long mvccVersion;
190            public long resourcePermissionId;
191            public long companyId;
192            public String name;
193            public int scope;
194            public String primKey;
195            public long primKeyId;
196            public long roleId;
197            public long ownerId;
198            public long actionIds;
199            public boolean viewActionId;
200    }