Add MountPointNode and its specializations
[yangtools.git] / yang / rfc8528-data-api / src / main / java / org / opendaylight / yangtools / rfc8528 / data / api / MountPointNodeFactoryResolver.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.eclipse.jdt.annotation.NonNullByDefault;
14 import org.opendaylight.yangtools.rfc8528.model.api.MountPointSchemaResolver;
15 import org.opendaylight.yangtools.rfc8528.model.api.StaticMountPointSchemaResolver;
16 import org.opendaylight.yangtools.rfc8528.model.api.YangLibraryConstants.ContainerName;
17 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 import org.opendaylight.yangtools.yang.model.parser.api.YangParserException;
20
21 @Beta
22 public interface MountPointNodeFactoryResolver extends MountPointSchemaResolver {
23     /**
24      * A resolver which can resolve the SchemaContext for use with mount point data based on the
25      * {@code ietf-yang-library} content of the mountpoint itself. This process requires two steps:
26      * <ul>
27      *   <li>{@link #findSchemaForLibrary(ContainerName)} is invoked to acquire a SchemaContext in which to interpret
28      *       one of the possible {@code ietf-yang-library} top-level containers.
29      *   </li>
30      *   <li>The container is normalized based on the returned context by the user of this interface and then
31      *       {@link LibraryContext#bindTo(ContainerNode)} is invoked to acquire the MountPointMetadata.
32      *   </li>
33      * </ul>
34      */
35     public interface Inline extends MountPointNodeFactoryResolver {
36         @NonNullByDefault
37         interface LibraryContext {
38             /**
39              * Return a SchemaContext capable of parsing the content of YANG Library.
40              *
41              * @return A SchemaContext instance
42              */
43             SchemaContext getLibraryContainerSchema();
44
45             /**
46              * Assemble the SchemaContext for specified normalized YANG Library top-level container.
47              *
48              * @param container Top-level YANG Library container
49              * @return An assembled SchemaContext
50              * @throws NullPointerException if container is null
51              * @throws YangParserException if the schema context cannot be assembled
52              */
53             MountPointNodeFactory bindTo(ContainerNode container) throws YangParserException;
54         }
55
56         /**
57          * Return the schema in which YANG Library container content should be interpreted.
58          *
59          * <p>
60          * Note this schema is not guaranteed to contain any augmentations, hence parsing could fail.
61          *
62          * @param containerName Top-level YANG Library container name
63          * @return The LibraryContext to use when interpreting the specified YANG Library container, or empty
64          * @throws NullPointerException if container is null
65          */
66         Optional<LibraryContext> findSchemaForLibrary(@NonNull ContainerName containerName);
67     }
68
69     @NonNullByDefault
70     interface SharedSchema extends MountPointNodeFactoryResolver, StaticMountPointSchemaResolver {
71
72         @Override
73         MountPointNodeFactory getSchema();
74     }
75 }