Fix somar complaints in equals methods 66/94766/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 11 Dec 2020 00:56:29 +0000 (01:56 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 23 Jan 2021 07:29:33 +0000 (08:29 +0100)
Sonar does not like if/else chains, simplify equals to simple
expressions.

Change-Id: I27087e85514a70bd3becde2fb5d41bcc11f6b8e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 864ad54598f5b24526c143b69e977e00adf74957)

yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/AliasEffectiveStatementImpl.java
yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/DefValEffectiveStatementImpl.java
yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/DisplayHintEffectiveStatementImpl.java
yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/ImpliedEffectiveStatementImpl.java
yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/MaxAccessEffectiveStatementImpl.java
yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/OidEffectiveStatementImpl.java
yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/SubIdEffectiveStatementImpl.java

index 1b03eb53a440cb8978ba62616d15b21714eeb989..4328a49216ee53c21d2fa05ba67a05ff389f1ec3 100644 (file)
@@ -55,22 +55,11 @@ final class AliasEffectiveStatementImpl extends UnknownEffectiveStatementBase<St
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof AliasEffectiveStatementImpl)) {
             return false;
         }
         final AliasEffectiveStatementImpl other = (AliasEffectiveStatementImpl) obj;
-        if (!Objects.equals(path, other.path)) {
-            return false;
-        }
-        if (!Objects.equals(getNodeType(), other.getNodeType())) {
-            return false;
-        }
-        if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
-            return false;
-        }
-        return true;
+        return Objects.equals(getNodeType(), other.getNodeType())
+            && Objects.equals(getNodeParameter(), other.getNodeParameter()) && Objects.equals(path, other.path);
     }
 }
index 1ed84019984a0c9d5ce085f81a9bb2caa540b1f6..cd0e594d5d89e6234cdc829820ee3d6549344ae5 100644 (file)
@@ -55,22 +55,11 @@ final class DefValEffectiveStatementImpl extends UnknownEffectiveStatementBase<S
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof DefValEffectiveStatementImpl)) {
             return false;
         }
         final DefValEffectiveStatementImpl other = (DefValEffectiveStatementImpl) obj;
-        if (!Objects.equals(path, other.path)) {
-            return false;
-        }
-        if (!Objects.equals(getNodeType(), other.getNodeType())) {
-            return false;
-        }
-        if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
-            return false;
-        }
-        return true;
+        return Objects.equals(getNodeType(), other.getNodeType())
+            && Objects.equals(getNodeParameter(), other.getNodeParameter()) && Objects.equals(path, other.path);
     }
 }
index 16ec310bfa0f81f7566f402b0b786ae87ce86eb6..fc79a60e3dd3ec37b0b07b2cf8a34cca31f2b463 100644 (file)
@@ -55,22 +55,11 @@ final class DisplayHintEffectiveStatementImpl extends UnknownEffectiveStatementB
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof DisplayHintEffectiveStatementImpl)) {
             return false;
         }
         final DisplayHintEffectiveStatementImpl other = (DisplayHintEffectiveStatementImpl) obj;
-        if (!Objects.equals(path, other.path)) {
-            return false;
-        }
-        if (!Objects.equals(getNodeType(), other.getNodeType())) {
-            return false;
-        }
-        if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
-            return false;
-        }
-        return true;
+        return Objects.equals(getNodeType(), other.getNodeType())
+            && Objects.equals(getNodeParameter(), other.getNodeParameter()) && Objects.equals(path, other.path);
     }
 }
index b3dd587a9edbbac07e42fe0a1ba02741676916a7..ef59ce5483703a58e5cb8f2b631c2f5ee3361317 100644 (file)
@@ -56,22 +56,11 @@ final class ImpliedEffectiveStatementImpl extends UnknownEffectiveStatementBase<
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof ImpliedEffectiveStatementImpl)) {
             return false;
         }
         final ImpliedEffectiveStatementImpl other = (ImpliedEffectiveStatementImpl) obj;
-        if (!Objects.equals(path, other.path)) {
-            return false;
-        }
-        if (!Objects.equals(getNodeType(), other.getNodeType())) {
-            return false;
-        }
-        if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
-            return false;
-        }
-        return true;
+        return Objects.equals(getNodeType(), other.getNodeType())
+            && Objects.equals(getNodeParameter(), other.getNodeParameter()) && Objects.equals(path, other.path);
     }
 }
index 7007758ffe50ae262d1bd17d1057bb56d6236b8f..9a57de5129e809c7b2befc5875cca0bc9f598a58 100644 (file)
@@ -61,22 +61,11 @@ final class MaxAccessEffectiveStatementImpl extends UnknownEffectiveStatementBas
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof MaxAccessEffectiveStatementImpl)) {
             return false;
         }
         final MaxAccessEffectiveStatementImpl other = (MaxAccessEffectiveStatementImpl) obj;
-        if (!Objects.equals(path, other.path)) {
-            return false;
-        }
-        if (!Objects.equals(getNodeType(), other.getNodeType())) {
-            return false;
-        }
-        if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
-            return false;
-        }
-        return true;
+        return Objects.equals(getNodeType(), other.getNodeType())
+            && Objects.equals(getNodeParameter(), other.getNodeParameter()) && Objects.equals(path, other.path);
     }
 }
index 5b71dea02187db1e1b76f3942d14c9ff53e99262..05588f8766c6fd60e5ef6e88eeb67d0d10959f13 100644 (file)
@@ -57,22 +57,11 @@ final class OidEffectiveStatementImpl extends UnknownEffectiveStatementBase<Obje
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof OidEffectiveStatementImpl)) {
             return false;
         }
         final OidEffectiveStatementImpl other = (OidEffectiveStatementImpl) obj;
-        if (!Objects.equals(path, other.path)) {
-            return false;
-        }
-        if (!Objects.equals(getNodeType(), other.getNodeType())) {
-            return false;
-        }
-        if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
-            return false;
-        }
-        return true;
+        return Objects.equals(getNodeType(), other.getNodeType())
+            && Objects.equals(getNodeParameter(), other.getNodeParameter()) && Objects.equals(path, other.path);
     }
 }
\ No newline at end of file
index e43ffe3bae1c4650af6b7e467b6a7379427b283c..9958da0074bae2397e227bdc3697b24f63bf863f 100644 (file)
@@ -57,22 +57,11 @@ final class SubIdEffectiveStatementImpl extends UnknownEffectiveStatementBase<Ui
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof SubIdEffectiveStatementImpl)) {
             return false;
         }
         final SubIdEffectiveStatementImpl other = (SubIdEffectiveStatementImpl) obj;
-        if (!Objects.equals(path, other.path)) {
-            return false;
-        }
-        if (!Objects.equals(getNodeType(), other.getNodeType())) {
-            return false;
-        }
-        if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
-            return false;
-        }
-        return true;
+        return Objects.equals(getNodeType(), other.getNodeType())
+            && Objects.equals(getNodeParameter(), other.getNodeParameter()) && Objects.equals(path, other.path);
     }
 }