1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.service.persistence;
16  
17  import com.liferay.portal.kernel.util.StringBundler;
18  import com.liferay.portal.kernel.util.StringPool;
19  
20  import java.io.Serializable;
21  
22  /**
23   * <a href="OrgGroupRolePK.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class OrgGroupRolePK implements Comparable<OrgGroupRolePK>, Serializable {
28      public long organizationId;
29      public long groupId;
30      public long roleId;
31  
32      public OrgGroupRolePK() {
33      }
34  
35      public OrgGroupRolePK(long organizationId, long groupId, long roleId) {
36          this.organizationId = organizationId;
37          this.groupId = groupId;
38          this.roleId = roleId;
39      }
40  
41      public long getOrganizationId() {
42          return organizationId;
43      }
44  
45      public void setOrganizationId(long organizationId) {
46          this.organizationId = organizationId;
47      }
48  
49      public long getGroupId() {
50          return groupId;
51      }
52  
53      public void setGroupId(long groupId) {
54          this.groupId = groupId;
55      }
56  
57      public long getRoleId() {
58          return roleId;
59      }
60  
61      public void setRoleId(long roleId) {
62          this.roleId = roleId;
63      }
64  
65      public int compareTo(OrgGroupRolePK pk) {
66          if (pk == null) {
67              return -1;
68          }
69  
70          int value = 0;
71  
72          if (organizationId < pk.organizationId) {
73              value = -1;
74          }
75          else if (organizationId > pk.organizationId) {
76              value = 1;
77          }
78          else {
79              value = 0;
80          }
81  
82          if (value != 0) {
83              return value;
84          }
85  
86          if (groupId < pk.groupId) {
87              value = -1;
88          }
89          else if (groupId > pk.groupId) {
90              value = 1;
91          }
92          else {
93              value = 0;
94          }
95  
96          if (value != 0) {
97              return value;
98          }
99  
100         if (roleId < pk.roleId) {
101             value = -1;
102         }
103         else if (roleId > pk.roleId) {
104             value = 1;
105         }
106         else {
107             value = 0;
108         }
109 
110         if (value != 0) {
111             return value;
112         }
113 
114         return 0;
115     }
116 
117     public boolean equals(Object obj) {
118         if (obj == null) {
119             return false;
120         }
121 
122         OrgGroupRolePK pk = null;
123 
124         try {
125             pk = (OrgGroupRolePK)obj;
126         }
127         catch (ClassCastException cce) {
128             return false;
129         }
130 
131         if ((organizationId == pk.organizationId) && (groupId == pk.groupId) &&
132                 (roleId == pk.roleId)) {
133             return true;
134         }
135         else {
136             return false;
137         }
138     }
139 
140     public int hashCode() {
141         return (String.valueOf(organizationId) + String.valueOf(groupId) +
142         String.valueOf(roleId)).hashCode();
143     }
144 
145     public String toString() {
146         StringBundler sb = new StringBundler(15);
147 
148         sb.append(StringPool.OPEN_CURLY_BRACE);
149 
150         sb.append("organizationId");
151         sb.append(StringPool.EQUAL);
152         sb.append(organizationId);
153 
154         sb.append(StringPool.COMMA);
155         sb.append(StringPool.SPACE);
156         sb.append("groupId");
157         sb.append(StringPool.EQUAL);
158         sb.append(groupId);
159 
160         sb.append(StringPool.COMMA);
161         sb.append(StringPool.SPACE);
162         sb.append("roleId");
163         sb.append(StringPool.EQUAL);
164         sb.append(roleId);
165 
166         sb.append(StringPool.CLOSE_CURLY_BRACE);
167 
168         return sb.toString();
169     }
170 }