Simplify equals() methods 04/101804/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 11 Jul 2022 20:42:32 +0000 (22:42 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 11 Jul 2022 20:43:27 +0000 (22:43 +0200)
Sonarcloud does not like the structure here, clean it up, formatting the
code a bit.

Change-Id: I3fa7c0302a31233059de67a2eae44beaf951b0a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
aaa-authn-api/src/main/java/org/opendaylight/aaa/api/model/Domain.java
aaa-authn-api/src/main/java/org/opendaylight/aaa/api/model/Grant.java
aaa-authn-api/src/main/java/org/opendaylight/aaa/api/model/Role.java
aaa-authn-api/src/main/java/org/opendaylight/aaa/api/model/User.java
aaa-authn-api/src/main/java/org/opendaylight/aaa/api/model/UserPwd.java

index 4050527731d507f425e9e33639fafc3fd5318098..3c7ffe9fc94cc1c69687a935124199edab7d970d 100644 (file)
@@ -21,15 +21,15 @@ public class Domain {
         return domainid;
     }
 
-    public void setDomainid(String id) {
-        this.domainid = id;
+    public void setDomainid(final String id) {
+        domainid = id;
     }
 
     public String getName() {
         return name;
     }
 
-    public void setName(String name) {
+    public void setName(final String name) {
         this.name = name;
     }
 
@@ -37,7 +37,7 @@ public class Domain {
         return description;
     }
 
-    public void setDescription(String description) {
+    public void setDescription(final String description) {
         this.description = description;
     }
 
@@ -45,7 +45,7 @@ public class Domain {
         return enabled;
     }
 
-    public void setEnabled(Boolean enabled) {
+    public void setEnabled(final Boolean enabled) {
         this.enabled = enabled;
     }
 
@@ -55,21 +55,16 @@ public class Domain {
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }
-
         if (obj == null || getClass() != obj.getClass()) {
             return false;
         }
-
-        Domain other = (Domain) obj;
-        if (Objects.equals(getName(), other.getName()) && Objects.equals(getDomainid(), other.getDomainid())
-                && Objects.equals(getDescription(), other.getDescription())) {
-            return true;
-        }
-        return false;
+        final Domain other = (Domain) obj;
+        return Objects.equals(getName(), other.getName()) && Objects.equals(getDomainid(), other.getDomainid())
+            && Objects.equals(getDescription(), other.getDescription());
     }
 
     @Override
index 883fb73df1e3b3016217d04513f1d59d8dff04c2..95050908212bdd9ddb1da7b5e8beefd7ced2ceef 100644 (file)
@@ -18,57 +18,52 @@ public class Grant {
     private String roleid;
 
     public String getGrantid() {
-        return this.grantid;
+        return grantid;
     }
 
-    public void setGrantid(String id) {
-        this.grantid = id;
+    public void setGrantid(final String id) {
+        grantid = id;
     }
 
     public String getDomainid() {
         return domainid;
     }
 
-    public void setDomainid(String id) {
-        this.domainid = id;
+    public void setDomainid(final String id) {
+        domainid = id;
     }
 
     public String getUserid() {
         return userid;
     }
 
-    public void setUserid(String id) {
-        this.userid = id;
+    public void setUserid(final String id) {
+        userid = id;
     }
 
     public String getRoleid() {
         return roleid;
     }
 
-    public void setRoleid(String id) {
-        this.roleid = id;
+    public void setRoleid(final String id) {
+        roleid = id;
     }
 
     @Override
     public int hashCode() {
-        return this.getUserid().hashCode();
+        return getUserid().hashCode();
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }
-
         if (obj == null || getClass() != obj.getClass()) {
             return false;
         }
-
-        Grant other = (Grant) obj;
-        if (Objects.equals(getDomainid(), other.getDomainid()) && Objects.equals(getRoleid(), other.getRoleid())
-                && Objects.equals(getUserid(), other.getUserid())) {
-            return true;
-        }
-        return false;
+        final Grant other = (Grant) obj;
+        return Objects.equals(getDomainid(), other.getDomainid()) && Objects.equals(getRoleid(), other.getRoleid())
+            && Objects.equals(getUserid(), other.getUserid());
     }
 }
index 10faed2b6c43a4e3ec6363fb861d128727028e50..b6ca6a0ee36098a4e55adb637805b73ea05121dd 100644 (file)
@@ -21,15 +21,15 @@ public class Role {
         return roleid;
     }
 
-    public void setRoleid(String id) {
-        this.roleid = id;
+    public void setRoleid(final String id) {
+        roleid = id;
     }
 
     public String getName() {
         return name;
     }
 
-    public void setName(String name) {
+    public void setName(final String name) {
         this.name = name;
     }
 
@@ -37,7 +37,7 @@ public class Role {
         return description;
     }
 
-    public void setDescription(String description) {
+    public void setDescription(final String description) {
         this.description = description;
     }
 
@@ -47,21 +47,16 @@ public class Role {
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }
-
         if (obj == null || getClass() != obj.getClass()) {
             return false;
         }
-
-        Role other = (Role) obj;
-        if (Objects.equals(getName(), other.getName()) && Objects.equals(getRoleid(), other.getRoleid())
-                && Objects.equals(getDescription(), other.getDescription())) {
-            return true;
-        }
-        return false;
+        final Role other = (Role) obj;
+        return Objects.equals(getName(), other.getName()) && Objects.equals(getRoleid(), other.getRoleid())
+            && Objects.equals(getDescription(), other.getDescription());
     }
 
     @Override
@@ -69,11 +64,11 @@ public class Role {
         return name;
     }
 
-    public void setDomainid(String domainid) {
+    public void setDomainid(final String domainid) {
         this.domainid = domainid;
     }
 
     public String getDomainid() {
-        return this.domainid;
+        return domainid;
     }
 }
index e92cbde8896799011f009c945d4aedc3165fb337..07bd1a9f4b355721e2251099d217f424ff371325 100644 (file)
@@ -29,15 +29,15 @@ public class User {
         return userid;
     }
 
-    public void setUserid(String id) {
-        this.userid = id;
+    public void setUserid(final String id) {
+        userid = id;
     }
 
     public String getName() {
         return name;
     }
 
-    public void setName(String name) {
+    public void setName(final String name) {
         this.name = name;
     }
 
@@ -45,7 +45,7 @@ public class User {
         return description;
     }
 
-    public void setDescription(String description) {
+    public void setDescription(final String description) {
         this.description = description;
     }
 
@@ -65,7 +65,7 @@ public class User {
         this.enabled = enabled;
     }
 
-    public void setEmail(String email) {
+    public void setEmail(final String email) {
         this.email = email;
     }
 
@@ -73,7 +73,7 @@ public class User {
         return email;
     }
 
-    public void setPassword(String password) {
+    public void setPassword(final String password) {
         this.password = password;
     }
 
@@ -81,19 +81,19 @@ public class User {
         return password;
     }
 
-    public void setSalt(String salt) {
+    public void setSalt(final String salt) {
         this.salt = salt;
     }
 
     public String getSalt() {
-        return this.salt;
+        return salt;
     }
 
     public String getDomainid() {
         return domainid;
     }
 
-    public void setDomainid(String domainid) {
+    public void setDomainid(final String domainid) {
         this.domainid = domainid;
     }
 
@@ -103,26 +103,18 @@ public class User {
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }
-
         if (obj == null || getClass() != obj.getClass()) {
             return false;
         }
-
-        User other = (User) obj;
-        if (Objects.equals(getName(), other.getName())
-                && Objects.equals(getEmail(), other.getEmail())
-                && isEnabled().equals(other.isEnabled())
-                && Objects.equals(getPassword(), other.getPassword())
-                && Objects.equals(getSalt(), other.getSalt())
-                && Objects.equals(getUserid(), other.getUserid())
-                && Objects.equals(getDescription(), other.getDescription())) {
-            return true;
-        }
-        return false;
+        final User other = (User) obj;
+        return Objects.equals(getName(), other.getName()) && Objects.equals(getEmail(), other.getEmail())
+            && isEnabled().equals(other.isEnabled()) && Objects.equals(getPassword(), other.getPassword())
+            && Objects.equals(getSalt(), other.getSalt()) && Objects.equals(getUserid(), other.getUserid())
+            && Objects.equals(getDescription(), other.getDescription());
     }
 
     @Override
index 4750616da9b860a47d41641df8bb7036795a5ce8..bca9b7cf84fb901b68de5dcfc64155008afba297 100644 (file)
@@ -5,15 +5,8 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.aaa.api.model;
 
-/**
- *
- * @author peter.mellquist@hp.com
- *
- */
-
 import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement(name = "userpwd")
@@ -25,16 +18,15 @@ public class UserPwd {
         return username;
     }
 
-    public void setUsername(String name) {
-        this.username = name;
+    public void setUsername(final String name) {
+        username = name;
     }
 
     public String getUserpwd() {
         return userpwd;
     }
 
-    public void setUserpwd(String pwd) {
-        this.userpwd = pwd;
+    public void setUserpwd(final String pwd) {
+        userpwd = pwd;
     }
-
 }