Add rfc8528-data-api
[yangtools.git] / yang / rfc8528-data-api / src / main / java / org / opendaylight / yangtools / rfc8528 / data / api / DynamicMountPointSchemaResolver.java
1 /*
2  * Copyright (c) 2019 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.rfc8528.data.api;
9
10 import com.google.common.annotations.Beta;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.rfc8528.model.api.MountPointSchemaResolver;
14 import org.opendaylight.yangtools.rfc8528.model.api.YangLibraryConstants.ContainerName;
15 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17 import org.opendaylight.yangtools.yang.model.parser.api.YangParserException;
18
19 /**
20  * A resolver which can resolve the SchemaContext for use with mount point data based on the
21  * {@code ietf-yang-library} content of the mountpoint itself. This process requires two steps:
22  * <ul>
23  *   <li>{@link #findContainerContext(ContainerName)} is invoked to acquire a SchemaContext in which to interpret
24  *       one of the possible {@code ietf-yang-library} top-level containers.
25  *   </li>
26  *   <li>The container is normalized based on the returned context by the user of this interface and then
27  *       {@link #assembleSchemaContext(ContainerNode)} is invoked to acquire the SchemaContext which will be used
28  *       to interpret the mount point data.
29  *   </li>
30  * </ul>
31  */
32 @Beta
33 public interface DynamicMountPointSchemaResolver extends MountPointSchemaResolver {
34     /**
35      * Return the schema in which YANG Library container content should be interpreted.
36      *
37      * @param containerName Top-level YANG Library container name
38      * @return The SchemaContext to use when interpreting the specified YANG Library container, or empty
39      * @throws NullPointerException if container is null
40      */
41     Optional<SchemaContext> findContainerContext(@NonNull ContainerName containerName);
42
43     /**
44      * Assemble the SchemaContext for specified normalized YANG Library top-level container.
45      *
46      * @param container Top-level YANG Library container
47      * @return An assembled SchemaContext
48      * @throws NullPointerException if container is null
49      * @throws YangParserException if the schema context cannot be assembled
50      */
51     @NonNull SchemaContext assembleSchemaContext(@NonNull ContainerNode container) throws YangParserException;
52 }