001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    
020    import java.io.Serializable;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class OrgGroupRolePK implements Comparable<OrgGroupRolePK>, Serializable {
026            public long organizationId;
027            public long groupId;
028            public long roleId;
029    
030            public OrgGroupRolePK() {
031            }
032    
033            public OrgGroupRolePK(long organizationId, long groupId, long roleId) {
034                    this.organizationId = organizationId;
035                    this.groupId = groupId;
036                    this.roleId = roleId;
037            }
038    
039            public long getOrganizationId() {
040                    return organizationId;
041            }
042    
043            public void setOrganizationId(long organizationId) {
044                    this.organizationId = organizationId;
045            }
046    
047            public long getGroupId() {
048                    return groupId;
049            }
050    
051            public void setGroupId(long groupId) {
052                    this.groupId = groupId;
053            }
054    
055            public long getRoleId() {
056                    return roleId;
057            }
058    
059            public void setRoleId(long roleId) {
060                    this.roleId = roleId;
061            }
062    
063            public int compareTo(OrgGroupRolePK pk) {
064                    if (pk == null) {
065                            return -1;
066                    }
067    
068                    int value = 0;
069    
070                    if (organizationId < pk.organizationId) {
071                            value = -1;
072                    }
073                    else if (organizationId > pk.organizationId) {
074                            value = 1;
075                    }
076                    else {
077                            value = 0;
078                    }
079    
080                    if (value != 0) {
081                            return value;
082                    }
083    
084                    if (groupId < pk.groupId) {
085                            value = -1;
086                    }
087                    else if (groupId > pk.groupId) {
088                            value = 1;
089                    }
090                    else {
091                            value = 0;
092                    }
093    
094                    if (value != 0) {
095                            return value;
096                    }
097    
098                    if (roleId < pk.roleId) {
099                            value = -1;
100                    }
101                    else if (roleId > pk.roleId) {
102                            value = 1;
103                    }
104                    else {
105                            value = 0;
106                    }
107    
108                    if (value != 0) {
109                            return value;
110                    }
111    
112                    return 0;
113            }
114    
115            public boolean equals(Object obj) {
116                    if (obj == null) {
117                            return false;
118                    }
119    
120                    OrgGroupRolePK pk = null;
121    
122                    try {
123                            pk = (OrgGroupRolePK)obj;
124                    }
125                    catch (ClassCastException cce) {
126                            return false;
127                    }
128    
129                    if ((organizationId == pk.organizationId) && (groupId == pk.groupId) &&
130                                    (roleId == pk.roleId)) {
131                            return true;
132                    }
133                    else {
134                            return false;
135                    }
136            }
137    
138            public int hashCode() {
139                    return (String.valueOf(organizationId) + String.valueOf(groupId) +
140                    String.valueOf(roleId)).hashCode();
141            }
142    
143            public String toString() {
144                    StringBundler sb = new StringBundler(15);
145    
146                    sb.append(StringPool.OPEN_CURLY_BRACE);
147    
148                    sb.append("organizationId");
149                    sb.append(StringPool.EQUAL);
150                    sb.append(organizationId);
151    
152                    sb.append(StringPool.COMMA);
153                    sb.append(StringPool.SPACE);
154                    sb.append("groupId");
155                    sb.append(StringPool.EQUAL);
156                    sb.append(groupId);
157    
158                    sb.append(StringPool.COMMA);
159                    sb.append(StringPool.SPACE);
160                    sb.append("roleId");
161                    sb.append(StringPool.EQUAL);
162                    sb.append(roleId);
163    
164                    sb.append(StringPool.CLOSE_CURLY_BRACE);
165    
166                    return sb.toString();
167            }
168    }