Simplify AbstractPathArgument.equals() 81/104981/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 22 Mar 2023 09:31:38 +0000 (10:31 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 22 Mar 2023 09:31:38 +0000 (10:31 +0100)
Use instanceof pattern to simplify the equals method.

Change-Id: I31eb8b095a701a43ece60008bc1b797a9ef6ebac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java

index 496dc1cb9e1d20af8d36e92da5cabf122295129d..d3e476cf835f1365aa357d60d66f4fb42a31c9d1 100644 (file)
@@ -683,15 +683,8 @@ public class InstanceIdentifier<T extends DataObject>
 
         @Override
         public final boolean equals(final Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (!(obj instanceof AbstractPathArgument)) {
-                return false;
-            }
-            final AbstractPathArgument<?> other = (AbstractPathArgument<?>) obj;
-            return type.equals(other.type) && Objects.equals(getKey(), other.getKey())
-                    && getCaseType().equals(other.getCaseType());
+            return this == obj || obj instanceof AbstractPathArgument<?> other && type.equals(other.type)
+                && Objects.equals(getKey(), other.getKey()) && getCaseType().equals(other.getCaseType());
         }
 
         @Override