Remove EffectiveStatement namespaces
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / stmt / DataTreeAwareEffectiveStatement.java
index 36812e324853bdadb3868f4cbb66eb6341b06406..afbf1e2d68bfb8c35690e47978fa03b9a118fb5d 100644 (file)
@@ -7,12 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.model.api.stmt;
 
-import static java.util.Objects.requireNonNull;
-import static org.opendaylight.yangtools.yang.model.api.stmt.DefaultMethodHelpers.filterOptional;
-
+import java.util.Collection;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
@@ -25,20 +22,17 @@ import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 public interface DataTreeAwareEffectiveStatement<A, D extends DeclaredStatement<A>>
         extends SchemaTreeAwareEffectiveStatement<A, D> {
     /**
-     * Namespace of {@code data node}s. This is a subtree of
-     * {@link SchemaTreeAwareEffectiveStatement.SchemaTreeNamespace} in that all data nodes are also schema nodes. The
+     * Return the mapping of {@code data tree} children of this statement. This is a subtree of
+     * {@link SchemaTreeAwareEffectiveStatement#schemaTreeNodes()} in that all data nodes are also schema nodes. The
      * structure of the tree is different, though, as {@code choice} and {@code case} statements are glossed over and
      * they do not contribute to the tree hierarchy -- only their children do.
      *
      * <p>
-     * This corresponds to the {@code data tree} view of a YANG-defined data.
+     * Note that returned statements are not necessarily direct substatements of this statement.
+     *
+     * @return All substatements participating on the {@code data tree}
      */
-    @NonNullByDefault
-    abstract class DataTreeNamespace extends EffectiveStatementNamespace<DataTreeEffectiveStatement<?>> {
-        private DataTreeNamespace() {
-            // Should never be instantiated
-        }
-    }
+    @NonNull Collection<DataTreeEffectiveStatement<?>> dataTreeNodes();
 
     /**
      * Find a {@code data tree} child {@link DataTreeEffectiveStatement}, as identified by its QName argument.
@@ -47,9 +41,7 @@ public interface DataTreeAwareEffectiveStatement<A, D extends DeclaredStatement<
      * @return Data tree child, or empty
      * @throws NullPointerException if {@code qname} is {@code null}
      */
-    default @NonNull Optional<DataTreeEffectiveStatement<?>> findDataTreeNode(final @NonNull QName qname) {
-        return get(DataTreeNamespace.class, requireNonNull(qname));
-    }
+    @NonNull Optional<DataTreeEffectiveStatement<?>> findDataTreeNode(@NonNull QName qname);
 
     /**
      * Find a {@code data tree} child {@link DataTreeEffectiveStatement}, as identified by its QName argument.
@@ -61,6 +53,6 @@ public interface DataTreeAwareEffectiveStatement<A, D extends DeclaredStatement<
      * @throws NullPointerException if any argument is {@code null}
      */
     default <E> @NonNull Optional<E> findDataTreeNode(final Class<E> type, final @NonNull QName qname) {
-        return filterOptional(type, findDataTreeNode(qname));
+        return DefaultMethodHelpers.filterOptional(findDataTreeNode(qname), type);
     }
 }