Add ModuleEffectiveStatement.namespace() 12/103312/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 21 Nov 2022 17:05:35 +0000 (18:05 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 21 Nov 2022 17:27:08 +0000 (18:27 +0100)
A module has to have exactly one namespace statement, expose it
from ModuleEffectiveStatement.

JIRA: YANGTOOLS-1466
Change-Id: I958cb5fca392029dd236d52e54527ab211ab8199
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

index 10705b58e15ca00c1239f23777813177209d88ab..cd29d981bde48ad4d4e26e72cdd96d6ff7f91487 100644 (file)
@@ -72,6 +72,18 @@ public non-sealed interface ModuleEffectiveStatement
         return YangStmtMapping.MODULE;
     }
 
+    /**
+     * Return this statement's {@code namespace} substatement.
+     *
+     * @implSpec
+     *      Default implementation uses {@link #findFirstEffectiveSubstatement(Class)} and throws a
+     *      {@link VerifyException} if a matching substatement is not found.
+     * @return A {@link NamespaceEffectiveStatement}
+     */
+    default @NonNull NamespaceEffectiveStatement namespace() {
+        return DefaultMethodHelpers.verifySubstatement(this, NamespaceEffectiveStatement.class);
+    }
+
     /**
      * Return this statement's {@code prefix} substatement.
      *