Use Objects.equals() in yang-model-api 07/27507/2
authorRobert Varga <rovarga@cisco.com>
Sun, 27 Sep 2015 16:25:06 +0000 (18:25 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 28 Sep 2015 07:26:36 +0000 (07:26 +0000)
Simplifies and clarifies the code.

Change-Id: I1dba9eeeb9ce69be6de9f0fd4088ac6afa7d0e25
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaPath.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/SchemaNodeIdentifier.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SourceIdentifier.java

index 6164a8f891d04179768a769c43d30318216ac5b3..04975deefafc9a6936a2bd9bacd29610bace8980 100644 (file)
@@ -313,21 +313,7 @@ public abstract class SchemaPath implements Immutable {
             return false;
         }
         final SchemaPath other = (SchemaPath) obj;
-
-        if (qname != null) {
-            if (!qname.equals(other.qname)) {
-                return false;
-            }
-        } else {
-            if (other.qname != null) {
-                return false;
-            }
-        }
-
-        if (parent == null) {
-            return other.parent == null;
-        }
-        return parent.equals(other.parent);
+        return Objects.equals(qname, other.qname) && Objects.equals(parent, other.parent);
     }
 
     @Override
index 33e8cbde3aeca4166ac6e3ae9efe896ca27cfe65..e4d9779741fdd8a43a6c19b6d47a44bf14fb0916 100644 (file)
@@ -319,21 +319,7 @@ public abstract class SchemaNodeIdentifier implements Immutable {
             return false;
         }
         final SchemaNodeIdentifier other = (SchemaNodeIdentifier) obj;
-
-        if (qname != null) {
-            if (!qname.equals(other.qname)) {
-                return false;
-            }
-        } else {
-            if (other.qname != null) {
-                return false;
-            }
-        }
-
-        if (parent == null) {
-            return other.parent == null;
-        }
-        return parent.equals(other.parent);
+        return Objects.equals(qname, other.qname) && Objects.equals(parent, other.parent);
     }
 
     @Override
index 43879624c99d9da581073e72d5afffa13296e3af..fba3630573038bbcc8d3c789e7c0b030372e3704 100644 (file)
@@ -143,21 +143,7 @@ public final class SourceIdentifier implements Identifier, Immutable {
             return false;
         }
         SourceIdentifier other = (SourceIdentifier) obj;
-        if (name == null) {
-            if (other.name != null) {
-                return false;
-            }
-        } else if (!name.equals(other.name)) {
-            return false;
-        }
-        if (revision == null) {
-            if (other.revision != null) {
-                return false;
-            }
-        } else if (!revision.equals(other.revision)) {
-            return false;
-        }
-        return true;
+        return Objects.equals(name, other.name) && Objects.equals(revision, other.revision);
     }
 
     public static SourceIdentifier create(final String moduleName, final Optional<String> revision) {