Remove EffectiveAugmentationSchema.create()
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / stmt / ModuleEffectiveStatement.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, 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 import org.opendaylight.yangtools.yang.common.QNameModule;
14 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
15 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
16 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
17 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
18
19 /**
20  * Effective view of a {@link ModuleStatement}.
21  */
22 @Beta
23 public interface ModuleEffectiveStatement
24         extends DataTreeAwareEffectiveStatement<Unqualified, ModuleStatement>, SchemaTreeRoot {
25     /**
26      * Namespace mapping all known prefixes in a module to their modules. Note this namespace includes the module
27      * in which it is instantiated.
28      */
29     abstract class PrefixToEffectiveModuleNamespace
30             extends IdentifierNamespace<String, @NonNull ModuleEffectiveStatement> {
31         private PrefixToEffectiveModuleNamespace() {
32             // This class should never be subclassed
33         }
34     }
35
36     /**
37      * Namespace mapping all known {@link QNameModule}s to their encoding prefixes. This includes the declaration
38      * from prefix/namespace/revision and all imports as they were resolved.
39      */
40     abstract class QNameModuleToPrefixNamespace extends IdentifierNamespace<QNameModule, @NonNull String> {
41         private QNameModuleToPrefixNamespace() {
42             // This class should never be subclassed
43         }
44     }
45
46     /**
47      * Namespace mapping all included submodules. The namespaces is keyed by submodule name.
48      */
49     abstract class NameToEffectiveSubmoduleNamespace
50             extends IdentifierNamespace<String, @NonNull SubmoduleEffectiveStatement> {
51         private NameToEffectiveSubmoduleNamespace() {
52             // This class should never be subclassed
53         }
54     }
55
56     /**
57      * Conformance type, as defined by <a href="https://datatracker.ietf.org/doc/html/rfc7895#page-9">RFC7895</a> and
58      * indirectly referenced in <a href="https://datatracker.ietf.org/doc/html/rfc7950#section-5.6.4">RFC7950</a>. The
59      * NMDA revision of <a href="https://datatracker.ietf.org/doc/html/rfc8525">YANG Library</a> does not directly
60      * define these, but makes a distiction on the same concept.
61      */
62     enum ConformanceType {
63         /**
64          * This module is being implemented. As per RFC7895:
65          * <pre>
66          *   Indicates that the server implements one or more
67          *   protocol-accessible objects defined in the YANG module
68          *   identified in this entry.  This includes deviation
69          *   statements defined in the module.
70          *
71          *   For YANG version 1.1 modules, there is at most one
72          *   module entry with conformance type 'implement' for a
73          *   particular module name, since YANG 1.1 requires that,
74          *   at most, one revision of a module is implemented.
75          *
76          *   For YANG version 1 modules, there SHOULD NOT be more
77          *   than one module entry for a particular module name.
78          * </pre>
79          */
80         IMPLEMENT,
81         /**
82          * This module is being used only for reusable constructs. As per RFC7895:
83          * <pre>
84          *   Indicates that the server imports reusable definitions
85          *   from the specified revision of the module but does
86          *   not implement any protocol-accessible objects from
87          *   this revision.
88          *
89          *   Multiple module entries for the same module name MAY
90          *   exist.  This can occur if multiple modules import the
91          *   same module but specify different revision dates in
92          *   the import statements.
93          * </pre>
94          */
95         IMPORT;
96     }
97
98     @Override
99     default StatementDefinition statementDefinition() {
100         return YangStmtMapping.MODULE;
101     }
102
103     /**
104      * {@inheritDoc}
105      *
106      * @implSpec
107      *     Default implementation defers to {@link #findSchemaTreeNode(java.util.List)}.
108      */
109     @Override
110     default Optional<SchemaTreeEffectiveStatement<?>> findSchemaTreeNode(final SchemaNodeIdentifier path) {
111         return findSchemaTreeNode(path.getNodeIdentifiers());
112     }
113
114     /**
115      * Get the local QNameModule of this module. All implementations need to override this default method.
116      *
117      * @return Local QNameModule
118      */
119     @NonNull QNameModule localQNameModule();
120
121     /**
122      * Return the conformance type of this module.
123      *
124      * @return Conformance type.
125      */
126     @NonNull ConformanceType conformance();
127 }