Bug 6414: Fixed DataNodeIterator's traverseModule method
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / Leafref.java
index 5a14d3097b7c2eb8fdf9c780e18fc3fb0582bf2e..e2688665bfad397526674b99628bdd69dbcb96ad 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.model.util;
 import com.google.common.base.Preconditions;
 import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@@ -22,7 +23,9 @@ import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
  * interface.
  *
  * @see LeafrefTypeDefinition
+ * @deprecated Use {@link org.opendaylight.yangtools.yang.model.util.type.BaseTypes#leafrefTypeBuilder(SchemaPath)} instead
  */
+@Deprecated
 public final class Leafref implements LeafrefTypeDefinition {
     private static final QName NAME = BaseTypes.constructQName("leafref");
     private static final SchemaPath PATH = SchemaPath.create(true, NAME);
@@ -34,8 +37,7 @@ public final class Leafref implements LeafrefTypeDefinition {
 
     @Deprecated
     public Leafref(final RevisionAwareXPath xpath) {
-        this(PATH,xpath);
-
+        this(PATH, xpath);
     }
 
     private Leafref(final SchemaPath path, final RevisionAwareXPath target) {
@@ -43,7 +45,7 @@ public final class Leafref implements LeafrefTypeDefinition {
         this.xpath = Preconditions.checkNotNull(target,"target must not be null.");
     }
 
-    public static Leafref create(final SchemaPath path,final RevisionAwareXPath target) {
+    public static Leafref create(final SchemaPath path, final RevisionAwareXPath target) {
         return new Leafref(path,target);
     }
 
@@ -59,7 +61,7 @@ public final class Leafref implements LeafrefTypeDefinition {
 
     @Override
     public Object getDefaultValue() {
-        return this;
+        return null;
     }
 
     @Override
@@ -101,7 +103,7 @@ public final class Leafref implements LeafrefTypeDefinition {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
+        result = prime * result + Objects.hashCode(xpath);
         return result;
     }
 
@@ -117,14 +119,7 @@ public final class Leafref implements LeafrefTypeDefinition {
             return false;
         }
         Leafref other = (Leafref) obj;
-        if (xpath == null) {
-            if (other.xpath != null) {
-                return false;
-            }
-        } else if (!xpath.equals(other.xpath)) {
-            return false;
-        }
-        return true;
+        return Objects.equals(xpath, other.xpath);
     }
 
     @Override