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.service.persistence;
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    
023    import java.io.Serializable;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     * @generated
028     */
029    @ProviderType
030    public class OrgGroupRolePK implements Comparable<OrgGroupRolePK>, Serializable {
031            public long organizationId;
032            public long groupId;
033            public long roleId;
034    
035            public OrgGroupRolePK() {
036            }
037    
038            public OrgGroupRolePK(long organizationId, long groupId, long roleId) {
039                    this.organizationId = organizationId;
040                    this.groupId = groupId;
041                    this.roleId = roleId;
042            }
043    
044            public long getOrganizationId() {
045                    return organizationId;
046            }
047    
048            public void setOrganizationId(long organizationId) {
049                    this.organizationId = organizationId;
050            }
051    
052            public long getGroupId() {
053                    return groupId;
054            }
055    
056            public void setGroupId(long groupId) {
057                    this.groupId = groupId;
058            }
059    
060            public long getRoleId() {
061                    return roleId;
062            }
063    
064            public void setRoleId(long roleId) {
065                    this.roleId = roleId;
066            }
067    
068            @Override
069            public int compareTo(OrgGroupRolePK pk) {
070                    if (pk == null) {
071                            return -1;
072                    }
073    
074                    int value = 0;
075    
076                    if (organizationId < pk.organizationId) {
077                            value = -1;
078                    }
079                    else if (organizationId > pk.organizationId) {
080                            value = 1;
081                    }
082                    else {
083                            value = 0;
084                    }
085    
086                    if (value != 0) {
087                            return value;
088                    }
089    
090                    if (groupId < pk.groupId) {
091                            value = -1;
092                    }
093                    else if (groupId > pk.groupId) {
094                            value = 1;
095                    }
096                    else {
097                            value = 0;
098                    }
099    
100                    if (value != 0) {
101                            return value;
102                    }
103    
104                    if (roleId < pk.roleId) {
105                            value = -1;
106                    }
107                    else if (roleId > pk.roleId) {
108                            value = 1;
109                    }
110                    else {
111                            value = 0;
112                    }
113    
114                    if (value != 0) {
115                            return value;
116                    }
117    
118                    return 0;
119            }
120    
121            @Override
122            public boolean equals(Object obj) {
123                    if (this == obj) {
124                            return true;
125                    }
126    
127                    if (!(obj instanceof OrgGroupRolePK)) {
128                            return false;
129                    }
130    
131                    OrgGroupRolePK pk = (OrgGroupRolePK)obj;
132    
133                    if ((organizationId == pk.organizationId) && (groupId == pk.groupId) &&
134                                    (roleId == pk.roleId)) {
135                            return true;
136                    }
137                    else {
138                            return false;
139                    }
140            }
141    
142            @Override
143            public int hashCode() {
144                    int hashCode = 0;
145    
146                    hashCode = HashUtil.hash(hashCode, organizationId);
147                    hashCode = HashUtil.hash(hashCode, groupId);
148                    hashCode = HashUtil.hash(hashCode, roleId);
149    
150                    return hashCode;
151            }
152    
153            @Override
154            public String toString() {
155                    StringBundler sb = new StringBundler(15);
156    
157                    sb.append(StringPool.OPEN_CURLY_BRACE);
158    
159                    sb.append("organizationId");
160                    sb.append(StringPool.EQUAL);
161                    sb.append(organizationId);
162    
163                    sb.append(StringPool.COMMA);
164                    sb.append(StringPool.SPACE);
165                    sb.append("groupId");
166                    sb.append(StringPool.EQUAL);
167                    sb.append(groupId);
168    
169                    sb.append(StringPool.COMMA);
170                    sb.append(StringPool.SPACE);
171                    sb.append("roleId");
172                    sb.append(StringPool.EQUAL);
173                    sb.append(roleId);
174    
175                    sb.append(StringPool.CLOSE_CURLY_BRACE);
176    
177                    return sb.toString();
178            }
179    }