2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.model.api.stmt;
10 import java.util.Collection;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
17 * Interface implemented by all {@link SchemaTreeAwareEffectiveStatement}s which can contain a {@code data tree} child.
19 * @param <A> Argument type
20 * @param <D> Class representing declared version of this statement.
22 public interface DataTreeAwareEffectiveStatement<A, D extends DeclaredStatement<A>>
23 extends SchemaTreeAwareEffectiveStatement<A, D> {
25 * Return the mapping of {@code data tree} children of this statement. This is a subtree of
26 * {@link SchemaTreeAwareEffectiveStatement#schemaTreeNodes()} in that all data nodes are also schema nodes. The
27 * structure of the tree is different, though, as {@code choice} and {@code case} statements are glossed over and
28 * they do not contribute to the tree hierarchy -- only their children do.
31 * Note that returned statements are not necessarily direct substatements of this statement.
33 * @return All substatements participating on the {@code data tree}
35 @NonNull Collection<DataTreeEffectiveStatement<?>> dataTreeNodes();
38 * Find a {@code data tree} child {@link DataTreeEffectiveStatement}, as identified by its QName argument.
40 * @param qname Child identifier
41 * @return Data tree child, or empty
42 * @throws NullPointerException if {@code qname} is {@code null}
44 @NonNull Optional<DataTreeEffectiveStatement<?>> findDataTreeNode(@NonNull QName qname);
47 * Find a {@code data tree} child {@link DataTreeEffectiveStatement}, as identified by its QName argument.
49 * @param <E> Effective substatement type
50 * @param type Effective substatement class
51 * @param qname Child identifier
52 * @return Data tree child, or empty
53 * @throws NullPointerException if any argument is {@code null}
55 default <E> @NonNull Optional<E> findDataTreeNode(final Class<E> type, final @NonNull QName qname) {
56 return DefaultMethodHelpers.filterOptional(findDataTreeNode(qname), type);