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