001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.service.persistence;
022:
023: import com.liferay.portal.kernel.util.StringMaker;
024: import com.liferay.portal.kernel.util.StringPool;
025:
026: import java.io.Serializable;
027:
028: /**
029: * <a href="OrgGroupRolePK.java.html"><b><i>View Source</i></b></a>
030: *
031: * @author Brian Wing Shun Chan
032: *
033: */
034: public class OrgGroupRolePK implements Comparable, Serializable {
035: public long organizationId;
036: public long groupId;
037: public long roleId;
038:
039: public OrgGroupRolePK() {
040: }
041:
042: public OrgGroupRolePK(long organizationId, long groupId, long roleId) {
043: this .organizationId = organizationId;
044: this .groupId = groupId;
045: this .roleId = roleId;
046: }
047:
048: public long getOrganizationId() {
049: return organizationId;
050: }
051:
052: public void setOrganizationId(long organizationId) {
053: this .organizationId = organizationId;
054: }
055:
056: public long getGroupId() {
057: return groupId;
058: }
059:
060: public void setGroupId(long groupId) {
061: this .groupId = groupId;
062: }
063:
064: public long getRoleId() {
065: return roleId;
066: }
067:
068: public void setRoleId(long roleId) {
069: this .roleId = roleId;
070: }
071:
072: public int compareTo(Object obj) {
073: if (obj == null) {
074: return -1;
075: }
076:
077: OrgGroupRolePK pk = (OrgGroupRolePK) obj;
078:
079: int value = 0;
080:
081: if (organizationId < pk.organizationId) {
082: value = -1;
083: } else if (organizationId > pk.organizationId) {
084: value = 1;
085: } else {
086: value = 0;
087: }
088:
089: if (value != 0) {
090: return value;
091: }
092:
093: if (groupId < pk.groupId) {
094: value = -1;
095: } else if (groupId > pk.groupId) {
096: value = 1;
097: } else {
098: value = 0;
099: }
100:
101: if (value != 0) {
102: return value;
103: }
104:
105: if (roleId < pk.roleId) {
106: value = -1;
107: } else if (roleId > pk.roleId) {
108: value = 1;
109: } else {
110: value = 0;
111: }
112:
113: if (value != 0) {
114: return value;
115: }
116:
117: return 0;
118: }
119:
120: public boolean equals(Object obj) {
121: if (obj == null) {
122: return false;
123: }
124:
125: OrgGroupRolePK pk = null;
126:
127: try {
128: pk = (OrgGroupRolePK) obj;
129: } catch (ClassCastException cce) {
130: return false;
131: }
132:
133: if ((organizationId == pk.organizationId)
134: && (groupId == pk.groupId) && (roleId == pk.roleId)) {
135: return true;
136: } else {
137: return false;
138: }
139: }
140:
141: public int hashCode() {
142: return (String.valueOf(organizationId)
143: + String.valueOf(groupId) + String.valueOf(roleId))
144: .hashCode();
145: }
146:
147: public String toString() {
148: StringMaker sm = new StringMaker();
149:
150: sm.append(StringPool.OPEN_CURLY_BRACE);
151:
152: sm.append("organizationId");
153: sm.append(StringPool.EQUAL);
154: sm.append(organizationId);
155:
156: sm.append(StringPool.COMMA);
157: sm.append(StringPool.SPACE);
158: sm.append("groupId");
159: sm.append(StringPool.EQUAL);
160: sm.append(groupId);
161:
162: sm.append(StringPool.COMMA);
163: sm.append(StringPool.SPACE);
164: sm.append("roleId");
165: sm.append(StringPool.EQUAL);
166: sm.append(roleId);
167:
168: sm.append(StringPool.CLOSE_CURLY_BRACE);
169:
170: return sm.toString();
171: }
172: }
|