Expose conformance type from module 49/98849/3
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 5 Dec 2021 19:39:04 +0000 (20:39 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 6 Dec 2021 00:27:01 +0000 (01:27 +0100)
RFC7950 indirectly defines various conformance types. Make sure we
expose that from ModuleEffectiveStatement. The actual value still needs
to be determinated.

JIRA: YANGTOOLS-837
Change-Id: I20d0b5800b50eaa7fed126e867895da5545d4175
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/ModuleEffectiveStatement.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/module/ModuleEffectiveStatementImpl.java

index d9f436fc715c74078e7cc6e87562a758ea18be47..a51c3320667a093580129b9ac08869ef3739fe39 100644 (file)
@@ -53,18 +53,53 @@ public interface ModuleEffectiveStatement
         }
     }
 
+    /**
+     * Conformance type, as defined by <a href="https://datatracker.ietf.org/doc/html/rfc7895#page-9">RFC7895</a> and
+     * indirectly referenced in <a href="https://datatracker.ietf.org/doc/html/rfc7950#section-5.6.4">RFC7950</a>. The
+     * NMDA revision of <a href="https://datatracker.ietf.org/doc/html/rfc8525">YANG Library</a> does not directly
+     * define these, but makes a distiction on the same concept.
+     */
+    enum ConformanceType {
+        /**
+         * This module is being implemented. As per RFC7895:
+         * <pre>
+         *   Indicates that the server implements one or more
+         *   protocol-accessible objects defined in the YANG module
+         *   identified in this entry.  This includes deviation
+         *   statements defined in the module.
+         *
+         *   For YANG version 1.1 modules, there is at most one
+         *   module entry with conformance type 'implement' for a
+         *   particular module name, since YANG 1.1 requires that,
+         *   at most, one revision of a module is implemented.
+         *
+         *   For YANG version 1 modules, there SHOULD NOT be more
+         *   than one module entry for a particular module name.
+         * </pre>
+         */
+        IMPLEMENT,
+        /**
+         * This module is being used only for reusable constructs. As per RFC7895:
+         * <pre>
+         *   Indicates that the server imports reusable definitions
+         *   from the specified revision of the module but does
+         *   not implement any protocol-accessible objects from
+         *   this revision.
+         *
+         *   Multiple module entries for the same module name MAY
+         *   exist.  This can occur if multiple modules import the
+         *   same module but specify different revision dates in
+         *   the import statements.
+         * </pre>
+         */
+        IMPORT;
+    }
+
     @Override
     default StatementDefinition statementDefinition() {
         return YangStmtMapping.MODULE;
     }
 
-    /**
-     * Get the local QNameModule of this module. All implementations need to override this default method.
-     *
-     * @return Local QNameModule
-     */
-    @NonNull QNameModule localQNameModule();
-
     /**
      * {@inheritDoc}
      *
@@ -75,4 +110,18 @@ public interface ModuleEffectiveStatement
     default Optional<SchemaTreeEffectiveStatement<?>> findSchemaTreeNode(final SchemaNodeIdentifier path) {
         return findSchemaTreeNode(path.getNodeIdentifiers());
     }
+
+    /**
+     * Get the local QNameModule of this module. All implementations need to override this default method.
+     *
+     * @return Local QNameModule
+     */
+    @NonNull QNameModule localQNameModule();
+
+    /**
+     * Return the conformance type of this module.
+     *
+     * @return Conformance type.
+     */
+    @NonNull ConformanceType conformance();
 }
index 71360a89deb24e8d9eff639bf22fc60e8dac939d..50309a2b9208836e4a5a9eb1f2754252d72c4b81 100644 (file)
@@ -92,6 +92,12 @@ final class ModuleEffectiveStatementImpl extends AbstractEffectiveModule<ModuleS
             .collect(ImmutableMap.toImmutableMap(IdentityEffectiveStatement::argument, Function.identity()));
     }
 
+    @Override
+    public ConformanceType conformance() {
+        // FIXME: YANGTOOLS-837: provide an accurate value here
+        return ConformanceType.IMPLEMENT;
+    }
+
     @Override
     public QNameModule localQNameModule() {
         return qnameModule;