001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.util.HashUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    
023    import java.io.Serializable;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     * @generated
028     */
029    @ProviderType
030    public class UserGroupGroupRolePK implements Comparable<UserGroupGroupRolePK>,
031            Serializable {
032            public long userGroupId;
033            public long groupId;
034            public long roleId;
035    
036            public UserGroupGroupRolePK() {
037            }
038    
039            public UserGroupGroupRolePK(long userGroupId, long groupId, long roleId) {
040                    this.userGroupId = userGroupId;
041                    this.groupId = groupId;
042                    this.roleId = roleId;
043            }
044    
045            public long getUserGroupId() {
046                    return userGroupId;
047            }
048    
049            public void setUserGroupId(long userGroupId) {
050                    this.userGroupId = userGroupId;
051            }
052    
053            public long getGroupId() {
054                    return groupId;
055            }
056    
057            public void setGroupId(long groupId) {
058                    this.groupId = groupId;
059            }
060    
061            public long getRoleId() {
062                    return roleId;
063            }
064    
065            public void setRoleId(long roleId) {
066                    this.roleId = roleId;
067            }
068    
069            @Override
070            public int compareTo(UserGroupGroupRolePK pk) {
071                    if (pk == null) {
072                            return -1;
073                    }
074    
075                    int value = 0;
076    
077                    if (userGroupId < pk.userGroupId) {
078                            value = -1;
079                    }
080                    else if (userGroupId > pk.userGroupId) {
081                            value = 1;
082                    }
083                    else {
084                            value = 0;
085                    }
086    
087                    if (value != 0) {
088                            return value;
089                    }
090    
091                    if (groupId < pk.groupId) {
092                            value = -1;
093                    }
094                    else if (groupId > pk.groupId) {
095                            value = 1;
096                    }
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                    }
108                    else if (roleId > pk.roleId) {
109                            value = 1;
110                    }
111                    else {
112                            value = 0;
113                    }
114    
115                    if (value != 0) {
116                            return value;
117                    }
118    
119                    return 0;
120            }
121    
122            @Override
123            public boolean equals(Object obj) {
124                    if (this == obj) {
125                            return true;
126                    }
127    
128                    if (!(obj instanceof UserGroupGroupRolePK)) {
129                            return false;
130                    }
131    
132                    UserGroupGroupRolePK pk = (UserGroupGroupRolePK)obj;
133    
134                    if ((userGroupId == pk.userGroupId) && (groupId == pk.groupId) &&
135                                    (roleId == pk.roleId)) {
136                            return true;
137                    }
138                    else {
139                            return false;
140                    }
141            }
142    
143            @Override
144            public int hashCode() {
145                    int hashCode = 0;
146    
147                    hashCode = HashUtil.hash(hashCode, userGroupId);
148                    hashCode = HashUtil.hash(hashCode, groupId);
149                    hashCode = HashUtil.hash(hashCode, roleId);
150    
151                    return hashCode;
152            }
153    
154            @Override
155            public String toString() {
156                    StringBundler sb = new StringBundler(15);
157    
158                    sb.append(StringPool.OPEN_CURLY_BRACE);
159    
160                    sb.append("userGroupId");
161                    sb.append(StringPool.EQUAL);
162                    sb.append(userGroupId);
163    
164                    sb.append(StringPool.COMMA);
165                    sb.append(StringPool.SPACE);
166                    sb.append("groupId");
167                    sb.append(StringPool.EQUAL);
168                    sb.append(groupId);
169    
170                    sb.append(StringPool.COMMA);
171                    sb.append(StringPool.SPACE);
172                    sb.append("roleId");
173                    sb.append(StringPool.EQUAL);
174                    sb.append(roleId);
175    
176                    sb.append(StringPool.CLOSE_CURLY_BRACE);
177    
178                    return sb.toString();
179            }
180    }