Simplify equals() methods
[aaa.git] / aaa-authn-api / src / main / java / org / opendaylight / aaa / api / model / Grant.java
1 /*
2  * Copyright (c) 2014, 2017 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.aaa.api.model;
9
10 import java.util.Objects;
11 import javax.xml.bind.annotation.XmlRootElement;
12
13 @XmlRootElement(name = "grant")
14 public class Grant {
15     private String grantid;
16     private String domainid;
17     private String userid;
18     private String roleid;
19
20     public String getGrantid() {
21         return grantid;
22     }
23
24     public void setGrantid(final String id) {
25         grantid = id;
26     }
27
28     public String getDomainid() {
29         return domainid;
30     }
31
32     public void setDomainid(final String id) {
33         domainid = id;
34     }
35
36     public String getUserid() {
37         return userid;
38     }
39
40     public void setUserid(final String id) {
41         userid = id;
42     }
43
44     public String getRoleid() {
45         return roleid;
46     }
47
48     public void setRoleid(final String id) {
49         roleid = id;
50     }
51
52     @Override
53     public int hashCode() {
54         return getUserid().hashCode();
55     }
56
57     @Override
58     public boolean equals(final Object obj) {
59         if (this == obj) {
60             return true;
61         }
62         if (obj == null || getClass() != obj.getClass()) {
63             return false;
64         }
65         final Grant other = (Grant) obj;
66         return Objects.equals(getDomainid(), other.getDomainid()) && Objects.equals(getRoleid(), other.getRoleid())
67             && Objects.equals(getUserid(), other.getUserid());
68     }
69 }