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