Simplify equals() methods
[aaa.git] / aaa-authn-api / src / main / java / org / opendaylight / aaa / api / model / Role.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 = "role")
14 public class Role {
15     private String roleid;
16     private String name;
17     private String description;
18     private String domainid;
19
20     public String getRoleid() {
21         return roleid;
22     }
23
24     public void setRoleid(final String id) {
25         roleid = id;
26     }
27
28     public String getName() {
29         return name;
30     }
31
32     public void setName(final String name) {
33         this.name = name;
34     }
35
36     public String getDescription() {
37         return description;
38     }
39
40     public void setDescription(final String description) {
41         this.description = description;
42     }
43
44     @Override
45     public int hashCode() {
46         return name != null ? name.hashCode() : 0;
47     }
48
49     @Override
50     public boolean equals(final Object obj) {
51         if (this == obj) {
52             return true;
53         }
54         if (obj == null || getClass() != obj.getClass()) {
55             return false;
56         }
57         final Role other = (Role) obj;
58         return Objects.equals(getName(), other.getName()) && Objects.equals(getRoleid(), other.getRoleid())
59             && Objects.equals(getDescription(), other.getDescription());
60     }
61
62     @Override
63     public String toString() {
64         return name;
65     }
66
67     public void setDomainid(final String domainid) {
68         this.domainid = domainid;
69     }
70
71     public String getDomainid() {
72         return domainid;
73     }
74 }