Remove EffectiveStatement namespaces
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / stmt / DataTreeAwareEffectiveStatement.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.model.api.stmt;
9
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;
15
16 /**
17  * Interface implemented by all {@link SchemaTreeAwareEffectiveStatement}s which can contain a {@code data tree} child.
18  *
19  * @param <A> Argument type
20  * @param <D> Class representing declared version of this statement.
21  */
22 public interface DataTreeAwareEffectiveStatement<A, D extends DeclaredStatement<A>>
23         extends SchemaTreeAwareEffectiveStatement<A, D> {
24     /**
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.
29      *
30      * <p>
31      * Note that returned statements are not necessarily direct substatements of this statement.
32      *
33      * @return All substatements participating on the {@code data tree}
34      */
35     @NonNull Collection<DataTreeEffectiveStatement<?>> dataTreeNodes();
36
37     /**
38      * Find a {@code data tree} child {@link DataTreeEffectiveStatement}, as identified by its QName argument.
39      *
40      * @param qname Child identifier
41      * @return Data tree child, or empty
42      * @throws NullPointerException if {@code qname} is {@code null}
43      */
44     @NonNull Optional<DataTreeEffectiveStatement<?>> findDataTreeNode(@NonNull QName qname);
45
46     /**
47      * Find a {@code data tree} child {@link DataTreeEffectiveStatement}, as identified by its QName argument.
48      *
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}
54      */
55     default <E> @NonNull Optional<E> findDataTreeNode(final Class<E> type, final @NonNull QName qname) {
56         return DefaultMethodHelpers.filterOptional(findDataTreeNode(qname), type);
57     }
58 }