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