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 static java.util.Objects.requireNonNull;
11 import static org.opendaylight.yangtools.yang.model.api.stmt.DefaultMethodHelpers.filterOptional;
13 import com.google.common.annotations.Beta;
14 import java.util.Optional;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.eclipse.jdt.annotation.NonNullByDefault;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
21 * Interface implemented by all {@link SchemaTreeAwareEffectiveStatement}s which can contain a {@code data tree} child.
23 * @param <A> Argument type
24 * @param <D> Class representing declared version of this statement.
25 * @author Robert Varga
28 public interface DataTreeAwareEffectiveStatement<A, D extends DeclaredStatement<A>>
29 extends SchemaTreeAwareEffectiveStatement<A, D> {
31 * Namespace of {@code data node}s. This is a subtree of {@link SchemaTreeAwareEffectiveStatement.Namespace} in that
32 * all data nodes are also schema nodes. The structure of the tree is different, though, as {@code choice}
33 * and {@code case} statements are glossed over and they do not contribute to the tree hierarchy -- only their
37 * This corresponds to the {@code data tree} view of a YANG-defined data.
40 abstract class Namespace extends EffectiveStatementNamespace<DataTreeEffectiveStatement<?>> {
42 // Should never be instantiated
47 * Find a {@code data tree} child {@link DataTreeEffectiveStatement}, as identified by its QName argument.
49 * @param qname Child identifier
50 * @return Data tree child, or empty
51 * @throws NullPointerException if {@code qname} is null
53 default @NonNull Optional<DataTreeEffectiveStatement<?>> findDataTreeNode(final @NonNull QName qname) {
54 return get(Namespace.class, requireNonNull(qname));
58 * Find a {@code data tree} child {@link DataTreeEffectiveStatement}, as identified by its QName argument.
60 * @param <E> Effective substatement type
61 * @param type Effective substatement class
62 * @param qname Child identifier
63 * @return Data tree child, or empty
64 * @throws NullPointerException if any argument is null
66 default <E> @NonNull Optional<E> findDataTreeNode(final Class<E> type, final @NonNull QName qname) {
67 return filterOptional(type, findDataTreeNode(qname));