Merge "Fix JDK8 compatibility"
[aaa.git] / aaa-authn-api / src / main / java / org / opendaylight / aaa / api / model / Grant.java
1 /*
2  * Copyright (c) 2014, 2015 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
9 package org.opendaylight.aaa.api.model;
10
11 /**
12  *
13  * @author peter.mellquist@hp.com
14  *
15  */
16
17
18 import javax.xml.bind.annotation.XmlRootElement;
19
20 @XmlRootElement(name = "grant")
21 public class Grant {
22    private String grantid;
23    private String domainid;
24    private String userid;
25    private String roleid;
26
27    public String getGrantid(){
28        return this.grantid;
29    }
30
31    public void setGrantid(String id){
32        this.grantid = id;
33    }
34
35    public String getDomainid() {
36       return domainid;
37    }
38
39    public void setDomainid(String id) {
40       this.domainid = id;
41    }
42
43    public String getUserid() {
44       return userid;
45    }
46
47    public void setUserid(String id) {
48       this.userid = id;
49    }
50
51    public String getRoleid() {
52       return roleid;
53    }
54
55    public void setRoleid(String id) {
56       this.roleid = id;
57    }
58
59    @Override
60    public int hashCode() {
61        return this.getUserid().hashCode();
62    }
63
64    @Override
65    public boolean equals(Object obj) {
66        Grant other = (Grant)obj;
67        if(other==null)
68            return false;
69        if(compareValues(getDomainid(), other.getDomainid()) &&
70           compareValues(getRoleid(), other.getRoleid()) &&
71           compareValues(getUserid(), other.getUserid()))
72               return true;
73        return false;
74    }
75
76    private boolean compareValues(Object a,Object b){
77        if(a==null && b!=null)
78            return false;
79        if(a!=null && b==null)
80            return false;
81        if(a==null && b==null)
82            return true;
83        if(a.equals(b))
84            return true;
85        return false;
86    }
87 }