Update TypeDefinition design
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / RevisionAwareXPathImpl.java
index c5852696e4ec14b9c516d00aae66b1de5397a72b..813f38d0570aaca2dd4247eaba7c0f055eef0b3f 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.model.util;
 
+import java.util.Objects;
 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 
 /**
- * The <code>default</code> implementation of Instance Rewision Aware XPath
+ * The <code>helper</code> implementation of Instance Rewision Aware XPath
  * interface.
- * 
+ *
  * @see RevisionAwareXPath
  */
 public class RevisionAwareXPathImpl implements RevisionAwareXPath {
@@ -20,10 +21,7 @@ public class RevisionAwareXPathImpl implements RevisionAwareXPath {
     private final String xpath;
     private final boolean absolute;
 
-    private static final int HASH_BOOLEAN_TRUE = 1231;
-    private static final int HASH_BOOLEAN_FALSE = 1237;
-
-    public RevisionAwareXPathImpl(String xpath, boolean absolute) {
+    public RevisionAwareXPathImpl(final String xpath, final boolean absolute) {
         this.xpath = xpath;
         this.absolute = absolute;
     }
@@ -37,13 +35,13 @@ public class RevisionAwareXPathImpl implements RevisionAwareXPath {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
-        result = prime * result + (absolute ? HASH_BOOLEAN_TRUE : HASH_BOOLEAN_FALSE);
+        result = prime * result + Objects.hashCode(xpath);
+        result = prime * result + Boolean.hashCode(absolute);
         return result;
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }
@@ -54,17 +52,7 @@ public class RevisionAwareXPathImpl implements RevisionAwareXPath {
             return false;
         }
         RevisionAwareXPathImpl other = (RevisionAwareXPathImpl) obj;
-        if (xpath == null) {
-            if (other.xpath != null) {
-                return false;
-            }
-        } else if (!xpath.equals(other.xpath)) {
-            return false;
-        }
-        if (absolute != other.absolute) {
-            return false;
-        }
-        return false;
+        return absolute == other.absolute && Objects.equals(xpath, other.xpath);
     }
 
     @Override