Rework NormalizedNode type hierarchy
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / tree / spi / AbstractContainerNode.java
index bd2a01698f5404eb1a8419767b09879789631d23..bfa719d25a24a81074c5ff23af4104bfb0f4677f 100644 (file)
@@ -7,24 +7,23 @@
  */
 package org.opendaylight.yangtools.yang.data.api.schema.tree.spi;
 
-import java.util.Optional;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.DistinctNodeContainer;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
 
 /**
  * A TreeNode capable of holding child nodes. The fact that any of the children
  * changed is tracked by the subtree version.
  */
 abstract class AbstractContainerNode extends AbstractTreeNode {
-    protected AbstractContainerNode(final NormalizedNode<?, ?> data, final Version version) {
+    protected AbstractContainerNode(final NormalizedNode data, final Version version) {
         super(data, version);
     }
 
     @SuppressWarnings("unchecked")
-    protected final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> castData() {
-        return (NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>) getData();
+    protected final DistinctNodeContainer<?, PathArgument, NormalizedNode> castData() {
+        return (DistinctNodeContainer<?, PathArgument, NormalizedNode>) getData();
     }
 
     protected final @Nullable TreeNode getChildFromData(final PathArgument childId) {
@@ -32,9 +31,9 @@ abstract class AbstractContainerNode extends AbstractTreeNode {
         return getChildFromData(castData(), childId, getVersion());
     }
 
-    static TreeNode getChildFromData(final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> data,
+    static TreeNode getChildFromData(final DistinctNodeContainer<?, PathArgument, NormalizedNode> data,
             final PathArgument childId, final Version version) {
-        final Optional<NormalizedNode<?, ?>> child = data.getChild(childId);
-        return child.isPresent() ? TreeNodeFactory.createTreeNode(child.get(), version) : null;
+        final NormalizedNode child = data.childByArg(childId);
+        return child != null ? TreeNodeFactory.createTreeNode(child, version) : null;
     }
 }