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;
12 import com.google.common.annotations.Beta;
13 import java.util.Optional;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
18 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
21 * Interface implemented by all {@link EffectiveStatement}s which can contain a {@code schema tree} child. This tree
22 * can be walked using {@link SchemaNodeIdentifier}, looking up each component of
23 * {@link SchemaNodeIdentifier#getNodeIdentifiers()} using {@link #findSchemaTreeNode(QName)}.
25 * @param <A> Argument type
26 * @param <D> Class representing declared version of this statement.
27 * @author Robert Varga
30 public interface SchemaTreeAwareEffectiveStatement<A, D extends DeclaredStatement<A>> extends EffectiveStatement<A, D> {
32 * Namespace of {@code schema node}s defined within this node.
34 * @param <T> Child statement type
35 * @author Robert Varga
38 abstract class Namespace<T extends SchemaTreeEffectiveStatement<?>> extends EffectiveStatementNamespace<T> {
40 // Should never be instantiated
45 * Find a {@code schema tree} child {@link SchemaTreeEffectiveStatement}, as identified by its QName argument.
47 * @param qname Child identifier
48 * @return Schema tree child, or empty
49 * @throws NullPointerException if {@code qname} is null
51 default <E extends SchemaTreeEffectiveStatement<?>> @NonNull Optional<E> findSchemaTreeNode(
52 final @NonNull QName qname) {
53 return get(Namespace.class, requireNonNull(qname));