Introduce model.util.type package
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / Leafref.java
index 16c45d01ba050eff06ab192789eae971cb59844b..eab8b22ba81e2469f1f09695343056aa479e1796 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;
@@ -58,7 +59,7 @@ public final class Leafref implements LeafrefTypeDefinition {
 
     @Override
     public Object getDefaultValue() {
-        return this;
+        return null;
     }
 
     @Override
@@ -100,7 +101,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;
     }
 
@@ -116,14 +117,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