Remove EffectiveStatement namespaces
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / stmt / SchemaTreeRoot.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, 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 com.google.common.annotations.Beta;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.NonNull;
13
14 /**
15  * Common interface implemented by entities which act as the root of the {@code schema tree} and are able to resolve an
16  * {@link SchemaNodeIdentifier} to a {@link SchemaTreeEffectiveStatement}.
17  */
18 @Beta
19 public interface SchemaTreeRoot {
20     /**
21      * Find a {@code schema tree} node based on its schema node identifier.
22      *
23      * @param path Absolute schema node identifier
24      * @return Found node, or empty
25      * @throws NullPointerException if {@code path} is null
26      */
27     @NonNull Optional<SchemaTreeEffectiveStatement<?>> findSchemaTreeNode(@NonNull SchemaNodeIdentifier path);
28
29     /**
30      * Find a {@code schema tree} node based on its schema node identifier.
31      *
32      * @implSpec
33      *     Default implementation defers to {@link #findSchemaTreeNode(SchemaNodeIdentifier)} and filters the result
34      *     using provided class.
35      *
36      * @param <T> requested node type
37      * @param type Request node class
38      * @param path Absolute schema node identifier
39      * @return Found node, or empty
40      * @throws NullPointerException if any argument is null
41      */
42     default <T> @NonNull Optional<T> findSchemaTreeNode(final @NonNull Class<T> type,
43             final @NonNull SchemaNodeIdentifier path) {
44         return DefaultMethodHelpers.filterOptional(findSchemaTreeNode(path), type);
45     }
46 }