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.ResourceTypePermission;
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 ResourceTypePermission in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see ResourceTypePermission
036     * @generated
037     */
038    @ProviderType
039    public class ResourceTypePermissionCacheModel implements CacheModel<ResourceTypePermission>,
040            Externalizable, MVCCModel {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof ResourceTypePermissionCacheModel)) {
048                            return false;
049                    }
050    
051                    ResourceTypePermissionCacheModel resourceTypePermissionCacheModel = (ResourceTypePermissionCacheModel)obj;
052    
053                    if ((resourceTypePermissionId == resourceTypePermissionCacheModel.resourceTypePermissionId) &&
054                                    (mvccVersion == resourceTypePermissionCacheModel.mvccVersion)) {
055                            return true;
056                    }
057    
058                    return false;
059            }
060    
061            @Override
062            public int hashCode() {
063                    int hashCode = HashUtil.hash(0, resourceTypePermissionId);
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(15);
081    
082                    sb.append("{mvccVersion=");
083                    sb.append(mvccVersion);
084                    sb.append(", resourceTypePermissionId=");
085                    sb.append(resourceTypePermissionId);
086                    sb.append(", companyId=");
087                    sb.append(companyId);
088                    sb.append(", groupId=");
089                    sb.append(groupId);
090                    sb.append(", name=");
091                    sb.append(name);
092                    sb.append(", roleId=");
093                    sb.append(roleId);
094                    sb.append(", actionIds=");
095                    sb.append(actionIds);
096                    sb.append("}");
097    
098                    return sb.toString();
099            }
100    
101            @Override
102            public ResourceTypePermission toEntityModel() {
103                    ResourceTypePermissionImpl resourceTypePermissionImpl = new ResourceTypePermissionImpl();
104    
105                    resourceTypePermissionImpl.setMvccVersion(mvccVersion);
106                    resourceTypePermissionImpl.setResourceTypePermissionId(resourceTypePermissionId);
107                    resourceTypePermissionImpl.setCompanyId(companyId);
108                    resourceTypePermissionImpl.setGroupId(groupId);
109    
110                    if (name == null) {
111                            resourceTypePermissionImpl.setName(StringPool.BLANK);
112                    }
113                    else {
114                            resourceTypePermissionImpl.setName(name);
115                    }
116    
117                    resourceTypePermissionImpl.setRoleId(roleId);
118                    resourceTypePermissionImpl.setActionIds(actionIds);
119    
120                    resourceTypePermissionImpl.resetOriginalValues();
121    
122                    return resourceTypePermissionImpl;
123            }
124    
125            @Override
126            public void readExternal(ObjectInput objectInput) throws IOException {
127                    mvccVersion = objectInput.readLong();
128                    resourceTypePermissionId = objectInput.readLong();
129                    companyId = objectInput.readLong();
130                    groupId = objectInput.readLong();
131                    name = objectInput.readUTF();
132                    roleId = objectInput.readLong();
133                    actionIds = objectInput.readLong();
134            }
135    
136            @Override
137            public void writeExternal(ObjectOutput objectOutput)
138                    throws IOException {
139                    objectOutput.writeLong(mvccVersion);
140                    objectOutput.writeLong(resourceTypePermissionId);
141                    objectOutput.writeLong(companyId);
142                    objectOutput.writeLong(groupId);
143    
144                    if (name == null) {
145                            objectOutput.writeUTF(StringPool.BLANK);
146                    }
147                    else {
148                            objectOutput.writeUTF(name);
149                    }
150    
151                    objectOutput.writeLong(roleId);
152                    objectOutput.writeLong(actionIds);
153            }
154    
155            public long mvccVersion;
156            public long resourceTypePermissionId;
157            public long companyId;
158            public long groupId;
159            public String name;
160            public long roleId;
161            public long actionIds;
162    }