Revert Merge "Bug 2366: new parser - Types & TypeDefs"
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / nodes / AbstractImmutableNormalizedValueAttrNode.java
index fa81857ee2314fa06a2ef41c82b298272b242cb0..ec615025ebd5def89fdadb5d04cdac283122cb48 100644 (file)
@@ -7,16 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.nodes;
 
+import com.google.common.base.MoreObjects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
 import java.util.Map;
-
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.collect.ImmutableMap;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
-public abstract class AbstractImmutableNormalizedValueAttrNode<K extends InstanceIdentifier.PathArgument,V>
+public abstract class AbstractImmutableNormalizedValueAttrNode<K extends YangInstanceIdentifier.PathArgument,V>
         extends AbstractImmutableNormalizedValueNode<K, V>
         implements AttributesContainer {
 
@@ -44,7 +42,7 @@ public abstract class AbstractImmutableNormalizedValueAttrNode<K extends Instanc
 
     @Override
     protected int valueHashCode() {
-        final int result = getValue().hashCode();
+        final int result = getValue() != null ? getValue().hashCode() : 1;
 // FIXME: are attributes part of hashCode/equals?
 //        for (final Entry<?, ?> a : attributes.entrySet()) {
 //            result = 31 * result + a.hashCode();
@@ -54,15 +52,20 @@ public abstract class AbstractImmutableNormalizedValueAttrNode<K extends Instanc
 
     @Override
     protected boolean valueEquals(final AbstractImmutableNormalizedNode<?, ?> other) {
-        if (!getValue().equals(other.getValue())) {
+        // We can not call directly getValue.equals because of Empty Type
+        // Definition leaves which allways have NULL value
+
+        if (!java.util.Objects.deepEquals(getValue(), other.getValue())) {
             return false;
         }
 
-// FIXME: are attributes part of hashCode/equals?
-//        final Set<Entry<QName, String>> tas = getAttributes().entrySet();
-//        final Set<Entry<QName, String>> oas = container.getAttributes().entrySet();
-//
-//        return tas.containsAll(oas) && oas.containsAll(tas);
+        // FIXME: are attributes part of hashCode/equals?
+        // final Set<Entry<QName, String>> tas = getAttributes().entrySet();
+        // final Set<Entry<QName, String>> oas =
+        // container.getAttributes().entrySet();
+        //
+        // return tas.containsAll(oas) && oas.containsAll(tas);
         return true;
     }
+
 }