Fix immutable NormalizedNode equality
[yangtools.git] / data / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / nodes / AbstractImmutableDataContainerNode.java
index 3d3556e1dcdaf287a3ab041feff157a56177ce9e..8490d827d79b775f47dc66573edd280a25212ef4 100644 (file)
@@ -59,7 +59,17 @@ public abstract class AbstractImmutableDataContainerNode<K extends PathArgument,
 
     @Override
     protected boolean valueEquals(final N other) {
-        return other instanceof AbstractImmutableDataContainerNode<?, ?> && children.equals(
-                ((AbstractImmutableDataContainerNode<?, ?>) other).children);
+        if (other instanceof AbstractImmutableDataContainerNode) {
+            return children.equals(((AbstractImmutableDataContainerNode<?, ?>) other).children);
+        }
+        if (size() != other.size()) {
+            return false;
+        }
+        for (var child : body()) {
+            if (!child.equals(other.childByArg(child.getIdentifier()))) {
+                return false;
+            }
+        }
+        return true;
     }
 }