Remove NamespaceStmtCtx.get(All)FromNamespace() 57/105257/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 5 Apr 2023 15:31:23 +0000 (17:31 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 5 Apr 2023 20:48:41 +0000 (22:48 +0200)
We have a slight overlap in method, address the two TODOs and remove the
methods.

Change-Id: Ief3143075c7518d59a6d6838e0ca7d77b5f7e087
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
36 files changed:
parser/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/AbstractIdentityAwareStatementSupport.java
parser/rfc8040-parser-support/src/main/java/org/opendaylight/yangtools/rfc8040/parser/OperationsCreateLeafStatements.java
parser/rfc8040-parser-support/src/main/java/org/opendaylight/yangtools/rfc8040/parser/OperationsValidateModuleAction.java
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/BuildGlobalContext.java
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/InferredStatementContext.java
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/namespace/StmtNamespaceContext.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/namespace/YangNamespaceContextNamespace.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveModule.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AbstractAugmentStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentInferenceAction.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/deviate/AbstractDeviateStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/ImportStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/RevisionImport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/list/ListStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ActionStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ChoiceStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DeviationStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/FeatureStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/GroupingStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/IdentityStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RpcStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/TypedefStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/module/ModuleStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/submodule/SubmoduleEffectiveStatementImpl.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/submodule/SubmoduleStatementSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/IdentityRefSpecificationSupport.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/uses/UsesStatementSupport.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/thirdparty/plugin/ThirdPartyExtensionEffectiveStatementImpl.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/ParserNamespaces.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/NamespaceStmtCtx.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ParserNamespace.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextUtils.java
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/SubstatementValidator.java

index d3bdb76456d0b0be0257aeda2ec62a1453cc39e9..858bb21a39caedadc9bdf827eaeeff61f7fd86dd 100644 (file)
@@ -67,7 +67,7 @@ abstract class AbstractIdentityAwareStatementSupport<D extends DeclaredStatement
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         final QName qname = stmt.getArgument();
         final StmtContext<?, ?, IdentityEffectiveStatement> identityCtx =
-            verifyNotNull(stmt.getFromNamespace(ParserNamespaces.IDENTITY, qname), "Failed to find identity %s", qname);
+            verifyNotNull(stmt.namespaceItem(ParserNamespaces.IDENTITY, qname), "Failed to find identity %s", qname);
         return createEffective(stmt.declared(), identityCtx.buildEffective(), substatements);
     }
 
index 6eb67bef1127e3d6dd05ea9d0f85073235177e18..043b06cff79228b8ec2bf986b8df606ab957e376 100644 (file)
@@ -56,7 +56,7 @@ final class OperationsCreateLeafStatements implements InferenceAction {
 
         final var prereqs = new ArrayList<Prerequisite<? extends StmtContext<?, ?, ?>>>();
         // FIXME: this not accurate: we need all sources, not just modules
-        for (var module : ietfRestconfModule.getAllFromNamespace(ParserNamespaces.MODULE).values()) {
+        for (var module : ietfRestconfModule.namespace(ParserNamespaces.MODULE).values()) {
             if (!ietfRestconfModule.equals(module)) {
                 prereqs.add(action.requiresCtx((StmtContext<?, ?, ?>)module, ModelProcessingPhase.EFFECTIVE_MODEL));
             }
@@ -98,8 +98,7 @@ final class OperationsCreateLeafStatements implements InferenceAction {
 
     private <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<X, Y>>
             StatementSupport<X, Y, Z> getSupport(final StatementDefinition def, final Class<Z> effectiveClass) {
-        final var tmp = verifyNotNull(operations.getFromNamespace(StatementSupport.NAMESPACE,
-            def.getStatementName()));
+        final var tmp = verifyNotNull(operations.namespaceItem(StatementSupport.NAMESPACE, def.getStatementName()));
         final var repr = tmp.definition().getEffectiveRepresentationClass();
         verify(effectiveClass.equals(repr), "Unexpected support %s representation %s", tmp, repr);
 
index 72f18a5a497214be452dcb70e8547f4da5e0f958..ee6f1419997f163f43d147ccd320a53271fa1b96 100644 (file)
@@ -54,8 +54,7 @@ final class OperationsValidateModuleAction implements InferenceAction {
         final Mutable<?, ?, ?> moduleCtx = prereq.resolve(ctx);
 
         // Check namespace and revision first
-        final QNameModule moduleQName =
-            moduleCtx.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, moduleCtx);
+        final QNameModule moduleQName = moduleCtx.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, moduleCtx);
         if (!YangDataConstants.RFC8040_MODULE.equals(moduleQName)) {
             return;
         }
index e23bd96d907d76a00098c58ed6203f451c60ff12..711917a55bba149f2e08cd8968d3f0a607e41d7a 100644 (file)
@@ -239,7 +239,7 @@ final class BuildGlobalContext extends NamespaceStorageSupport implements Regist
     }
 
     private static SourceIdentifier createSourceIdentifier(final StmtContext<?, ?, ?> root) {
-        final QNameModule qNameModule = root.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, root);
+        final QNameModule qNameModule = root.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, root);
         final Object arg = root.getArgument();
         verify(arg instanceof Unqualified, "Unexpected argument %s", arg);
 
index 7a4d16c23952e9b6afdbe1cb43a5a8fae9dba5ab..6a8df4941b5f72c8e9f2026b4db8f3661320f00e 100644 (file)
@@ -452,7 +452,7 @@ final class InferredStatementContext<A, D extends DeclaredStatement<A>, E extend
         if (prototype instanceof InferredStatementContext<?, ?, ?> inferredPrototype) {
             // Note: we need to access namespace here, as the target statement may have already been populated, in which
             //       case we want to obtain the statement in local namespace storage.
-            template = inferredPrototype.getFromNamespace(ParserNamespaces.schemaTree(), templateQName);
+            template = inferredPrototype.namespaceItem(ParserNamespaces.schemaTree(), templateQName);
         } else {
             template = prototype.allSubstatementsStream()
                 .filter(stmt -> stmt.producesEffective(SchemaTreeEffectiveStatement.class)
index edade5f26878f6e34208206ff1efb8764a114ee4..175ac471e098eadcb10bcfa3e0df97a4c3347904 100644 (file)
@@ -466,7 +466,7 @@ abstract class ReactorStmtCtx<A, D extends DeclaredStatement<A>, E extends Effec
 
     @Override
     public final void setUnsupported() {
-        this.isSupportedToBuildEffective = false;
+        isSupportedToBuildEffective = false;
     }
 
     @Override
@@ -485,8 +485,7 @@ abstract class ReactorStmtCtx<A, D extends DeclaredStatement<A>, E extends Effec
          */
         if (isParentSupportedByFeatures()) {
             // If the set of supported features has not been provided, all features are supported by default.
-            final Set<QName> supportedFeatures = getFromNamespace(ParserNamespaces.SUPPORTED_FEATURES,
-                Empty.value());
+            final Set<QName> supportedFeatures = namespaceItem(ParserNamespaces.SUPPORTED_FEATURES, Empty.value());
             if (supportedFeatures == null || StmtContextUtils.checkFeatureSupport(this, supportedFeatures)) {
                 flags |= SET_SUPPORTED_BY_FEATURES;
                 return true;
index 33e371cfe157d113eb4f222f0761b92a96622638..badc36d316e8cbd5aafdca9917a88718bfd8a965 100644 (file)
@@ -427,16 +427,16 @@ final class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeha
     }
 
     private PrefixResolver prefixes() {
-        final var allImports = root.getAllFromNamespace(ParserNamespaces.IMPORT_PREFIX_TO_MODULECTX);
+        final var allImports = root.namespace(ParserNamespaces.IMPORT_PREFIX_TO_MODULECTX);
         if (allImports != null) {
             allImports.forEach((key, value) ->
-                prefixToModuleMap.put(key, root.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, value)));
+                prefixToModuleMap.put(key, root.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, value)));
         }
 
-        final var allBelongsTo = root.getAllFromNamespace(ParserNamespaces.BELONGSTO_PREFIX_TO_MODULECTX);
+        final var allBelongsTo = root.namespace(ParserNamespaces.BELONGSTO_PREFIX_TO_MODULECTX);
         if (allBelongsTo != null) {
             allBelongsTo.forEach((key, value) ->
-                prefixToModuleMap.put(key, root.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, value)));
+                prefixToModuleMap.put(key, root.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, value)));
         }
 
         return prefixToModuleMap;
index ad882421e8823d6df7e95824618b08f792051da6..b9aaaf70577634f9e79a7e1881966a40248576d8 100644 (file)
@@ -595,7 +595,7 @@ abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E extends
 
     final <K, V> void onNamespaceItemAddedAction(final ParserNamespace<K, V> type, final K key,
             final OnNamespaceItemAdded listener) {
-        final Object potential = getFromNamespace(type, key);
+        final Object potential = namespaceItem(type, key);
         if (potential != null) {
             LOG.trace("Listener on {} key {} satisfied immediately", type, key);
             listener.namespaceItemAdded(this, type, key, potential);
index 250b3833d199ea55ec0321da2dd16cef53530a1c..f0f69a44745809bf0f696544b67b3252eaff636e 100644 (file)
@@ -33,21 +33,19 @@ final class StmtNamespaceContext implements YangNamespaceContext {
 
     StmtNamespaceContext(final StmtContext<?, ?, ?> ctx) {
         // QNameModule -> prefix mappings
-        final Map<QNameModule, String> qnameToPrefix = ctx.getAllFromNamespace(ModuleQNameToPrefix.INSTANCE);
+        final Map<QNameModule, String> qnameToPrefix = ctx.namespace(ModuleQNameToPrefix.INSTANCE);
         moduleToPrefix = qnameToPrefix == null ? ImmutableBiMap.of() : ImmutableBiMap.copyOf(qnameToPrefix);
 
         // Additional mappings
         final Map<String, QNameModule> additional = new HashMap<>();
-        final Map<String, StmtContext<?, ?, ?>> imports = ctx.getAllFromNamespace(
-            ParserNamespaces.IMPORT_PREFIX_TO_MODULECTX);
+        final Map<String, StmtContext<?, ?, ?>> imports = ctx.namespace(ParserNamespaces.IMPORT_PREFIX_TO_MODULECTX);
         if (imports != null) {
             for (Entry<String, StmtContext<?, ?, ?>> entry : imports.entrySet()) {
                 if (!moduleToPrefix.containsValue(entry.getKey())) {
-                    QNameModule qnameModule = ctx.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME,
-                        entry.getValue());
+                    QNameModule qnameModule = ctx.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, entry.getValue());
                     if (qnameModule == null && ctx.producesDeclared(SubmoduleStatement.class)) {
-                        qnameModule = ctx.getFromNamespace(ParserNamespaces.MODULE_NAME_TO_QNAME,
-                            ctx.getFromNamespace(ParserNamespaces.BELONGSTO_PREFIX_TO_MODULE_NAME, entry.getKey()));
+                        qnameModule = ctx.namespaceItem(ParserNamespaces.MODULE_NAME_TO_QNAME,
+                            ctx.namespaceItem(ParserNamespaces.BELONGSTO_PREFIX_TO_MODULE_NAME, entry.getKey()));
                     }
 
                     if (qnameModule != null) {
@@ -57,11 +55,10 @@ final class StmtNamespaceContext implements YangNamespaceContext {
             }
         }
         if (ctx.producesDeclared(SubmoduleStatement.class)) {
-            final Map<String, Unqualified> belongsTo = ctx.getAllFromNamespace(
-                ParserNamespaces.BELONGSTO_PREFIX_TO_MODULE_NAME);
+            final Map<String, Unqualified> belongsTo = ctx.namespace(ParserNamespaces.BELONGSTO_PREFIX_TO_MODULE_NAME);
             if (belongsTo != null) {
                 for (Entry<String, Unqualified> entry : belongsTo.entrySet()) {
-                    final QNameModule module = ctx.getFromNamespace(ParserNamespaces.MODULE_NAME_TO_QNAME,
+                    final QNameModule module = ctx.namespaceItem(ParserNamespaces.MODULE_NAME_TO_QNAME,
                         entry.getValue());
                     if (module != null && !additional.containsKey(entry.getKey())) {
                         additional.put(entry.getKey(), module);
index 1884ce3577fe46a3c3c3d7ca0ff74d6e805bc7ca..b241252e8cd1e13040e33b6576ac613e63929d88 100644 (file)
@@ -30,7 +30,7 @@ public final class YangNamespaceContextNamespace {
 
     public static @NonNull YangNamespaceContext computeIfAbsent(final StmtContext<?, ?, ?> ctx) {
         final RootStmtContext<?, ?, ?> root = ctx.getRoot();
-        YangNamespaceContext ret = ctx.getFromNamespace(INSTANCE, root);
+        YangNamespaceContext ret = ctx.namespaceItem(INSTANCE, root);
         if (ret == null) {
             verify(ctx instanceof Mutable, "Cannot populate namespace context to %s", ctx);
             ret = new StmtNamespaceContext(root);
index 6e9f11897bd7420e6e1f37b31779ca396adae3f1..970222ea293283bb36f44a92e1897fff62b66e0b 100644 (file)
@@ -87,9 +87,9 @@ public abstract class AbstractEffectiveModule<D extends DeclaredStatement<Unqual
             }
         }
 
-        this.groupings = ImmutableSet.copyOf(mutableGroupings);
-        this.typeDefinitions = ImmutableSet.copyOf(mutableTypeDefinitions);
-        this.uses = ImmutableSet.copyOf(mutableUses);
+        groupings = ImmutableSet.copyOf(mutableGroupings);
+        typeDefinitions = ImmutableSet.copyOf(mutableTypeDefinitions);
+        uses = ImmutableSet.copyOf(mutableUses);
     }
 
     @Override
@@ -205,7 +205,7 @@ public abstract class AbstractEffectiveModule<D extends DeclaredStatement<Unqual
             .map(imp -> imp.prefix().argument())
             .forEach(pfx -> {
                 final var importedCtx =
-                    verifyNotNull(stmt.getFromNamespace(ParserNamespaces.IMPORT_PREFIX_TO_MODULECTX, pfx),
+                    verifyNotNull(stmt.namespaceItem(ParserNamespaces.IMPORT_PREFIX_TO_MODULECTX, pfx),
                         "Failed to resolve prefix %s", pfx);
                 builder.put(pfx, (ModuleEffectiveStatement) importedCtx.buildEffective());
             });
index e1c4faeeef311e4821efced27eb4969d98e6250f..2de5f0f6380205423afa96a36a7d02871b2de8dd 100644 (file)
@@ -123,7 +123,7 @@ abstract class AbstractAugmentStatementSupport
             final List<? extends StmtContext<?, ?, ?>> substatements) {
         // Pick up the marker left by onFullDefinitionDeclared() inference action. If it is present we need to pass our
         // children through target's implicit wrapping.
-        final var implicitDef = stmt.getFromNamespace(AugmentImplicitHandlingNamespace.INSTANCE, Empty.value());
+        final var implicitDef = stmt.namespaceItem(AugmentImplicitHandlingNamespace.INSTANCE, Empty.value());
         return implicitDef == null ? substatements
             : Lists.transform(substatements, subCtx -> implicitDef.wrapWithImplicit(subCtx));
     }
index 54ee72d8abbcece084c0afca75b38c864b208bcc..3cac5cb71c8fa5e538f565f3bf450a3651daf4b9 100644 (file)
@@ -282,7 +282,7 @@ final class AugmentInferenceAction implements InferenceAction {
          * the same QName. We must find the Container and the Grouping must be
          * ignored as disallowed augment target.
          */
-        final Collection<?> allowedAugmentTargets = substatementCtx.getFromNamespace(
+        final Collection<?> allowedAugmentTargets = substatementCtx.namespaceItem(
             ValidationBundles.NAMESPACE, ValidationBundleType.SUPPORTED_AUGMENT_TARGETS);
 
         // if no allowed target is returned we consider all targets allowed
index f137d12310c6d14ffc22e46e26a20b03c0126331..10fe3a28478163b7d9a2bb1ae6af6afe7c7ac8b4 100644 (file)
@@ -224,13 +224,13 @@ abstract class AbstractDeviateStatementSupport
     private static boolean isDeviationSupported(
             final Mutable<DeviateKind, DeviateStatement, DeviateEffectiveStatement> deviateStmtCtx,
             final SchemaNodeIdentifier deviationTarget) {
-        final SetMultimap<QNameModule, QNameModule> modulesDeviatedByModules = deviateStmtCtx.getFromNamespace(
+        final SetMultimap<QNameModule, QNameModule> modulesDeviatedByModules = deviateStmtCtx.namespaceItem(
                 ParserNamespaces.MODULES_DEVIATED_BY, Empty.value());
         if (modulesDeviatedByModules == null) {
             return true;
         }
 
-        final QNameModule currentModule = deviateStmtCtx.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME,
+        final QNameModule currentModule = deviateStmtCtx.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME,
                 deviateStmtCtx.getRoot());
         final QNameModule targetModule = Iterables.getLast(deviationTarget.getNodeIdentifiers()).getModule();
 
index 66e148e75fd99e883d5769e1eba60edbeefadf5c..84f4494b5923623a34047cf8a28a8800bb643d7f 100644 (file)
@@ -96,7 +96,7 @@ public final class ImportStatementSupport
             public void apply(final InferenceContext ctx) {
                 final StmtContext<?, ?, ?> importedModuleContext = imported.resolve(ctx);
                 verify(moduleName.equals(importedModuleContext.getArgument()));
-                final XMLNamespace importedModuleNamespace = verifyNotNull(importedModuleContext.getFromNamespace(
+                final XMLNamespace importedModuleNamespace = verifyNotNull(importedModuleContext.namespaceItem(
                     ParserNamespaces.MODULE_NAME_TO_NAMESPACE, moduleName));
                 final String impPrefix = SourceException.throwIfNull(
                     firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class), stmt,
@@ -145,6 +145,6 @@ public final class ImportStatementSupport
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         InferenceException.throwIf(substatements.isEmpty(), stmt, "Unexpected empty effective import statement");
         return EffectiveStatements.createImport(stmt.declared(), substatements,
-            verifyNotNull(stmt.getFromNamespace(ImportedVersionNamespace.INSTANCE, Empty.value())));
+            verifyNotNull(stmt.namespaceItem(ImportedVersionNamespace.INSTANCE, Empty.value())));
     }
 }
index 21b643406e3318bac3eb7fc6f5cd09b7dc4e644c..517ac367faf7440f31f5e3321d999ac9d8f9a255 100644 (file)
@@ -59,12 +59,12 @@ final class RevisionImport {
             public void apply(final InferenceContext ctx) {
                 final StmtContext<?, ?, ?> importedModule = imported.resolve(ctx);
 
-                final SourceIdentifier importedModuleIdentifier = stmt.getFromNamespace(
+                final SourceIdentifier importedModuleIdentifier = stmt.namespaceItem(
                     ParserNamespaces.MODULECTX_TO_SOURCE, importedModule);
                 stmt.addToNs(ImportedVersionNamespace.INSTANCE, Empty.value(), importedModuleIdentifier);
 
                 final QNameModule mod = InferenceException.throwIfNull(
-                    stmt.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, importedModule), stmt,
+                    stmt.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, importedModule), stmt,
                     "Failed to find module of %s", importedModule);
 
                 linkageTarget.resolve(ctx).addToNs(ParserNamespaces.IMPORTED_MODULE, importedModuleIdentifier,
index 6d397f26c4ee806cf4017a4851ace9bb612d355d..e0b6e4ef450e7b1195819ee8295be87a58b5fcb9 100644 (file)
@@ -216,7 +216,7 @@ public final class ListStatementSupport
 
     private static void warnConfigList(final @NonNull Current<QName, ListStatement> stmt) {
         final StatementSourceReference ref = stmt.sourceReference();
-        final Boolean warned = stmt.getFromNamespace(ConfigListWarningNamespace.INSTANCE, ref);
+        final Boolean warned = stmt.namespaceItem(ConfigListWarningNamespace.INSTANCE, ref);
         // Hacky check if we have issued a warning for the original statement
         if (warned == null) {
             final StmtContext<?, ?, ?> ctx = stmt.caerbannog();
index c9a155ffb58633deb6502dab3f4b7ae06bce3f98..ebdb5c3b3d914b9bd2c7a69c76fbe29bb4b91e40 100644 (file)
@@ -133,6 +133,6 @@ public final class ActionStatementSupport extends
     private static void appendImplicitSubstatement(final Mutable<QName, ActionStatement, ActionEffectiveStatement> stmt,
             final QName substatementName) {
         stmt.addEffectiveSubstatement(stmt.createUndeclaredSubstatement(
-            verifyNotNull(stmt.getFromNamespace(StatementSupport.NAMESPACE, substatementName)), null));
+            verifyNotNull(stmt.namespaceItem(StatementSupport.NAMESPACE, substatementName)), null));
     }
 }
index 4b99a133712769ee06642734e853e78fd075b586..12d192f303de2f71b7043239a68f95138e313c4c 100644 (file)
@@ -117,7 +117,7 @@ public final class ChoiceStatementSupport
         if (!caseShorthands.contains(stmtDef)) {
             return Optional.empty();
         }
-        return Optional.of(verifyNotNull(parent.getFromNamespace(StatementSupport.NAMESPACE,
+        return Optional.of(verifyNotNull(parent.namespaceItem(StatementSupport.NAMESPACE,
             YangStmtMapping.CASE.getStatementName())));
     }
 
index 00a0cfaa6466815f1b851b1e36bc77e1d26c3d99..20da74a1fc7dac49aafa54e55bfddd08528d921c 100644 (file)
@@ -59,11 +59,10 @@ public final class DeviationStatementSupport
         if (root.producesDeclared(SubmoduleStatement.class)) {
             // root is submodule, we need to find the module we belong to. We can rely on there being exactly one
             // belongs-to statement, enforced SubmoduleStatementSupport's validator.
-            root = Iterables.getOnlyElement(
-                root.getAllFromNamespace(ParserNamespaces.BELONGSTO_PREFIX_TO_MODULECTX).values());
+            root = Iterables.getOnlyElement(root.namespace(ParserNamespaces.BELONGSTO_PREFIX_TO_MODULECTX).values());
         }
 
-        final var currentModule = verifyNotNull(ctx.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, root),
+        final var currentModule = verifyNotNull(ctx.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, root),
             "Failed to find QName for %s", root);
         final var targetModule = Iterables.getLast(ctx.getArgument().getNodeIdentifiers()).getModule();
         if (currentModule.equals(targetModule)) {
index 2f5df123a7b986e02e5fa364ab9ec9d4f5d606d2..fcab16fcf51a7e83fe676fb08c2b22a78d64742e 100644 (file)
@@ -57,7 +57,7 @@ public final class FeatureStatementSupport
         stmt.addContext(ParserNamespaces.FEATURE, stmt.getArgument(), stmt);
 
         // Do not build effective statement if supported features does not include this feature
-        final var supportedFeatures = stmt.getFromNamespace(ParserNamespaces.SUPPORTED_FEATURES, Empty.value());
+        final var supportedFeatures = stmt.namespaceItem(ParserNamespaces.SUPPORTED_FEATURES, Empty.value());
         if (supportedFeatures != null && !supportedFeatures.contains(stmt.getArgument())) {
             stmt.setUnsupported();
         }
index e8b13e578a566fd8dce0a4414a279d31fb5eb05a..d8921a6e9936229f3effc3cf8faa4011ac8e88b9 100644 (file)
@@ -155,7 +155,7 @@ public final class GroupingStatementSupport
 
     private static void checkConflict(final StmtContext<?, ?, ?> parent, final StmtContext<QName, ?, ?> stmt) {
         final QName arg = stmt.getArgument();
-        final StmtContext<?, ?, ?> existing = parent.getFromNamespace(ParserNamespaces.GROUPING, arg);
+        final StmtContext<?, ?, ?> existing = parent.namespaceItem(ParserNamespaces.GROUPING, arg);
         SourceException.throwIf(existing != null, stmt, "Duplicate name for grouping %s", arg);
     }
 }
index f51bdd37b318f2fa31faf0a84edb8622bf1655fa..6b5e637bb1f228838702889094b1142716a0160d 100644 (file)
@@ -82,7 +82,7 @@ public final class IdentityStatementSupport
     public void onStatementDefinitionDeclared(
             final Mutable<QName, IdentityStatement, IdentityEffectiveStatement> stmt) {
         final QName qname = stmt.getArgument();
-        final StmtContext<?, ?, ?> prev = stmt.getFromNamespace(ParserNamespaces.IDENTITY, qname);
+        final StmtContext<?, ?, ?> prev = stmt.namespaceItem(ParserNamespaces.IDENTITY, qname);
         SourceException.throwIf(prev != null, stmt, "Duplicate identity definition %s", qname);
         stmt.addToNs(ParserNamespaces.IDENTITY, qname, stmt);
     }
@@ -111,7 +111,7 @@ public final class IdentityStatementSupport
             if (substatement instanceof BaseEffectiveStatement) {
                 final QName qname = ((BaseEffectiveStatement) substatement).argument();
                 final IdentityEffectiveStatement identity =
-                        verifyNotNull(stmt.getFromNamespace(ParserNamespaces.IDENTITY, qname),
+                        verifyNotNull(stmt.namespaceItem(ParserNamespaces.IDENTITY, qname),
                             "Failed to find identity %s", qname)
                         .buildEffective();
                 verify(identity instanceof IdentitySchemaNode, "%s is not a IdentitySchemaNode", identity);
index 9753a9f2e3d1a394b75d721d0205689c6fa36266..5750f96d14bbd65ad43dec1189010d90f7baedec 100644 (file)
@@ -101,6 +101,6 @@ public final class RpcStatementSupport extends AbstractSchemaTreeStatementSuppor
     private static void appendImplicitSubstatement(final Mutable<QName, RpcStatement, RpcEffectiveStatement> stmt,
             final QName substatementName) {
         stmt.addEffectiveSubstatement(stmt.createUndeclaredSubstatement(
-            verifyNotNull(stmt.getFromNamespace(StatementSupport.NAMESPACE, substatementName)), null));
+            verifyNotNull(stmt.namespaceItem(StatementSupport.NAMESPACE, substatementName)), null));
     }
 }
index ce58e47f0975f2aff65cf696b46dd0a7a29dfd2a..2d2546d97edc70f2fd0c695649e575cd20ed4bd0 100644 (file)
@@ -128,7 +128,7 @@ public final class TypedefStatementSupport extends
 
     private static void checkConflict(final StmtContext<?, ?, ?> parent, final StmtContext<QName, ?, ?> stmt) {
         final QName arg = stmt.getArgument();
-        final StmtContext<?, ?, ?> existing = parent.getFromNamespace(ParserNamespaces.TYPE, arg);
+        final StmtContext<?, ?, ?> existing = parent.namespaceItem(ParserNamespaces.TYPE, arg);
         // RFC7950 sections 5.5 and 6.2.1: identifiers must not be shadowed
         SourceException.throwIf(existing != null, stmt, "Duplicate name for typedef %s", arg);
     }
index a49038da2b856003c83b3f6fda9f93080906934a..44e770572337b0dce4adb6c56ec0bf0c1f24460a 100644 (file)
@@ -155,7 +155,7 @@ public final class ModuleStatementSupport
         final Revision revisionDate = StmtContextUtils.getLatestRevision(stmt.declaredSubstatements()).orElse(null);
         final QNameModule qNameModule = QNameModule.create(moduleNs, revisionDate).intern();
         final StmtContext<?, ModuleStatement, ModuleEffectiveStatement> possibleDuplicateModule =
-                stmt.getFromNamespace(ParserNamespaces.NAMESPACE_TO_MODULE, qNameModule);
+                stmt.namespaceItem(ParserNamespaces.NAMESPACE_TO_MODULE, qNameModule);
         if (possibleDuplicateModule != null && possibleDuplicateModule != stmt) {
             throw new SourceException(stmt, "Module namespace collision: %s. At %s", qNameModule.getNamespace(),
                 possibleDuplicateModule.sourceReference());
index 8c72e5e5dd377f93af201f4c2c315511c08dfe18..1860bab4e0d4ba7cc1c4c4cb8107161e62d3333b 100644 (file)
@@ -55,7 +55,7 @@ final class SubmoduleEffectiveStatementImpl
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         super(stmt, substatements, findSubmodulePrefix(stmt, substatements));
 
-        final QNameModule belongsToModuleQName = stmt.getFromNamespace(ParserNamespaces.MODULE_NAME_TO_QNAME,
+        final QNameModule belongsToModuleQName = stmt.namespaceItem(ParserNamespaces.MODULE_NAME_TO_QNAME,
             findBelongsTo(stmt, substatements).argument());
 
         final Builder<String, ModuleEffectiveStatement> prefixToModuleBuilder = ImmutableMap.builder();
index a87551ed65ec3d48b3ca92754d240263fa62f0ec..af77a0cc09c1eab162ce37ecf4a2b0a315abc7cb 100644 (file)
@@ -123,7 +123,7 @@ public final class SubmoduleStatementSupport
             StmtContextUtils.getLatestRevision(stmt.declaredSubstatements()).orElse(null));
 
         final StmtContext<?, SubmoduleStatement, SubmoduleEffectiveStatement>
-            possibleDuplicateSubmodule = stmt.getFromNamespace(ParserNamespaces.SUBMODULE, submoduleIdentifier);
+            possibleDuplicateSubmodule = stmt.namespaceItem(ParserNamespaces.SUBMODULE, submoduleIdentifier);
         if (possibleDuplicateSubmodule != null && possibleDuplicateSubmodule != stmt) {
             throw new SourceException(stmt, "Submodule name collision: %s. At %s", stmt.rawArgument(),
                 possibleDuplicateSubmodule.sourceReference());
index 2b3b136b23c1ed57948dfcb7c7ad38d084df9cd2..84c40bc54bf9a6697a81f0a80a8a2cad5ca3f734 100644 (file)
@@ -65,7 +65,7 @@ final class IdentityRefSpecificationSupport extends AbstractTypeSupport<Identity
                 StmtContextUtils.findAllDeclaredSubstatements(stmt, BaseStatement.class);
         for (StmtContext<QName, BaseStatement, ?> baseStmt : baseStatements) {
             final QName baseIdentity = baseStmt.getArgument();
-            final StmtContext<?, ?, ?> stmtCtx = stmt.getFromNamespace(ParserNamespaces.IDENTITY, baseIdentity);
+            final StmtContext<?, ?, ?> stmtCtx = stmt.namespaceItem(ParserNamespaces.IDENTITY, baseIdentity);
             InferenceException.throwIfNull(stmtCtx, stmt,
                 "Referenced base identity '%s' doesn't exist in given scope (module, imported modules, submodules)",
                 baseIdentity.getLocalName());
@@ -100,7 +100,7 @@ final class IdentityRefSpecificationSupport extends AbstractTypeSupport<Identity
             if (subStmt instanceof BaseEffectiveStatement) {
                 final QName identityQName = ((BaseEffectiveStatement) subStmt).argument();
                 final IdentityEffectiveStatement baseIdentity =
-                    verifyNotNull(stmt.getFromNamespace(ParserNamespaces.IDENTITY, identityQName)).buildEffective();
+                    verifyNotNull(stmt.namespaceItem(ParserNamespaces.IDENTITY, identityQName)).buildEffective();
                 verify(baseIdentity instanceof IdentitySchemaNode, "Statement %s is not an IdentitySchemaNode",
                     baseIdentity);
                 builder.addIdentity((IdentitySchemaNode) baseIdentity);
index 935ba001772be266fb4024562ad374c2570ffccd..a69b42d7c14252c9403947fa4465c079aa191c81 100644 (file)
@@ -140,7 +140,7 @@ public final class UsesStatementSupport
     protected UsesEffectiveStatement createEffective(final Current<QName, UsesStatement> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         final EffectiveStatement<?, ?> source =
-            verifyNotNull(stmt.getFromNamespace(SourceGroupingNamespace.INSTANCE, Empty.value())).buildEffective();
+            verifyNotNull(stmt.namespaceItem(SourceGroupingNamespace.INSTANCE, Empty.value())).buildEffective();
         verify(source instanceof GroupingDefinition, "Unexpected source %s", source);
         final GroupingDefinition sourceGrouping = (GroupingDefinition) source;
 
@@ -254,7 +254,7 @@ public final class UsesStatementSupport
     private static QNameModule getNewQNameModule(final StmtContext<?, ?, ?> targetCtx,
             final StmtContext<?, ?, ?> stmtContext) {
         if (targetCtx.getParentContext() == null) {
-            return targetCtx.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, targetCtx);
+            return targetCtx.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, targetCtx);
         }
         if (targetCtx.publicDefinition() == YangStmtMapping.AUGMENT) {
             return StmtContextUtils.getModuleQName(targetCtx);
@@ -342,7 +342,7 @@ public final class UsesStatementSupport
     }
 
     private static boolean isSupportedRefineSubstatement(final StmtContext<?, ?, ?> refineSubstatementCtx) {
-        final Collection<?> supportedRefineSubstatements = refineSubstatementCtx.getFromNamespace(
+        final Collection<?> supportedRefineSubstatements = refineSubstatementCtx.namespaceItem(
                 ValidationBundles.NAMESPACE, ValidationBundleType.SUPPORTED_REFINE_SUBSTATEMENTS);
 
         return supportedRefineSubstatements == null || supportedRefineSubstatements.isEmpty()
index d4a32c5ff71ffde91801fa204c199807fde734bd..40d4c942a8577455fa694ebaf1e26c529a1ef68b 100644 (file)
@@ -22,7 +22,7 @@ final class ThirdPartyExtensionEffectiveStatementImpl
     ThirdPartyExtensionEffectiveStatementImpl(final Current<String, ThirdPartyExtensionStatement> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         super(stmt.declared(), stmt.argument(), stmt.history(), substatements);
-        valueFromNamespace = stmt.getFromNamespace(ThirdPartyNamespace.INSTANCE, Empty.value());
+        valueFromNamespace = stmt.namespaceItem(ThirdPartyNamespace.INSTANCE, Empty.value());
     }
 
     @Override
index ca0a049390f8e4de99231c3e53224eb69e70e781..5fc9fd532b4681b7c52ac171385f5e936f2992d2 100644 (file)
@@ -270,13 +270,13 @@ public final class ParserNamespaces {
         }
 
         QName nextPath = iterator.next();
-        var current = root.getFromNamespace(schemaTree(), nextPath);
+        var current = root.namespaceItem(schemaTree(), nextPath);
         if (current == null) {
             return Optional.ofNullable(tryToFindUnknownStatement(nextPath.getLocalName(), root));
         }
         while (current != null && iterator.hasNext()) {
             nextPath = iterator.next();
-            final var nextNodeCtx = current.getFromNamespace(schemaTree(), nextPath);
+            final var nextNodeCtx = current.namespaceItem(schemaTree(), nextPath);
             if (nextNodeCtx == null) {
                 return Optional.ofNullable(tryToFindUnknownStatement(nextPath.getLocalName(), current));
             }
index dece704498b709dae69a5e9be981c81aaec3dfe6..a4aed68c91281f91247fb1643dae4526ca8c1149 100644 (file)
@@ -54,33 +54,4 @@ public interface NamespaceStmtCtx extends CommonStmtCtx {
      * @return Namespace portion stored in this node, if available
      */
     <K, V> @Nullable Map<K, V> localNamespacePortion(@NonNull ParserNamespace<K, V> nsType);
-
-    /**
-     * Return the selected namespace.
-     *
-     * @param <K> namespace key type
-     * @param <V> namespace value type
-     * @param nsType namespace type class
-     * @return Namespace contents, if available
-     */
-    // TODO: migrate users away
-    default <K, V> Map<K, V> getAllFromNamespace(final @NonNull ParserNamespace<K, V> nsType) {
-        return namespace(nsType);
-    }
-
-    /**
-     * Return a value associated with specified key within a namespace.
-     *
-     * @param type Namespace type
-     * @param key Key
-     * @param <K> namespace key type
-     * @param <V> namespace value type
-     * @param <T> key type
-     * @return Value, or null if there is no element
-     * @throws NamespaceNotAvailableException when the namespace is not available.
-     */
-    // TODO: migrate users away
-    default <K, V, T extends K> @Nullable V getFromNamespace(final @NonNull ParserNamespace<K, V> type, final T key) {
-        return namespaceItem(type, key);
-    }
 }
index f735eac9823ca6a5e041309a2fb81015baa3efa8..d561117a4a9e0b7a168c7d29ed3563448bf54ccb 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.yangtools.concepts.Identifier;
 /**
  * {@link ParserNamespace} serves as common superclass for namespaces used during parser operation. Each such namespace,
  * is a type-captured subclass. This type capture of namespace allows for handy type-safe reading methods such as
- * {@link NamespaceStmtCtx#getFromNamespace(ParserNamespace, Object)} and still allows introduction of new namespaces
+ * {@link NamespaceStmtCtx#namespaceItem(ParserNamespace, Object)} and still allows introduction of new namespaces
  * without need to change APIs.
  *
  * @param <K> Identifier type
index 6906c329b9ccc38887f76ff85de06aabca7bec33..73c48cf47fb771ddb13c0ae5903bcddd43e7e741 100644 (file)
@@ -540,7 +540,7 @@ public final class StmtContextUtils {
         if (ctx.producesDeclared(ModuleStatement.class)) {
             return lookupModuleQName(ctx, ctx);
         } else if (ctx.producesDeclared(SubmoduleStatement.class)) {
-            final var belongsTo = ctx.getAllFromNamespace(ParserNamespaces.BELONGSTO_PREFIX_TO_MODULECTX);
+            final var belongsTo = ctx.namespace(ParserNamespaces.BELONGSTO_PREFIX_TO_MODULECTX);
             if (belongsTo == null || belongsTo.isEmpty()) {
                 throw new IllegalArgumentException(ctx + " does not have belongs-to linkage resolved");
             }
@@ -552,7 +552,7 @@ public final class StmtContextUtils {
 
     private static @NonNull QNameModule lookupModuleQName(final NamespaceStmtCtx storage,
             final StmtContext<?, ?, ?> module) {
-        final var ret = storage.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, module);
+        final var ret = storage.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, module);
         if (ret == null) {
             throw new IllegalArgumentException("Failed to look up QNameModule for " + module + " in " + storage);
         }
@@ -561,15 +561,15 @@ public final class StmtContextUtils {
 
     public static QNameModule getModuleQNameByPrefix(final StmtContext<?, ?, ?> ctx, final String prefix) {
         final var root = ctx.getRoot();
-        final var importedModule = root.getFromNamespace(ParserNamespaces.IMPORT_PREFIX_TO_MODULECTX, prefix);
-        final var qnameModule = ctx.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, importedModule);
+        final var importedModule = root.namespaceItem(ParserNamespaces.IMPORT_PREFIX_TO_MODULECTX, prefix);
+        final var qnameModule = ctx.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, importedModule);
         if (qnameModule != null) {
             return qnameModule;
         }
 
         if (root.producesDeclared(SubmoduleStatement.class)) {
-            return ctx.getFromNamespace(ParserNamespaces.MODULE_NAME_TO_QNAME,
-                root.getFromNamespace(ParserNamespaces.BELONGSTO_PREFIX_TO_MODULE_NAME, prefix));
+            return ctx.namespaceItem(ParserNamespaces.MODULE_NAME_TO_QNAME,
+                root.namespaceItem(ParserNamespaces.BELONGSTO_PREFIX_TO_MODULE_NAME, prefix));
         }
 
         return null;
index acd99a17292ef3cc21d9ec6fae71fcb0559d8384..816e639988fc071aed891253e02cfa1a47a442c2 100644 (file)
@@ -125,11 +125,11 @@ public final class SubstatementValidator {
             final int value = entry.getValue().getValue();
 
             if (cardinality == null) {
-                if (ctx.getFromNamespace(ParserNamespaces.EXTENSION, key.getStatementName()) == null) {
+                if (ctx.namespaceItem(ParserNamespaces.EXTENSION, key.getStatementName()) == null) {
                     final StmtContext<?, ?, ?> root = ctx.getRoot();
                     throw new InvalidSubstatementException(ctx, "%s is not valid for %s. Error in module %s (%s)", key,
                         currentStatement, root.rawArgument(),
-                        ctx.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, root));
+                        ctx.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, root));
                 }
 
                 continue;
@@ -141,7 +141,7 @@ public final class SubstatementValidator {
                     throw new InvalidSubstatementException(ctx,
                         "Minimal count of %s for %s is %s, detected %s. Error in module %s (%s)", key, currentStatement,
                         cardinality.getMin(), value, root.rawArgument(),
-                        ctx.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, root));
+                        ctx.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, root));
                 }
 
                 // Encountered a mandatory statement, hence we are not missing it
@@ -152,7 +152,7 @@ public final class SubstatementValidator {
                 throw new InvalidSubstatementException(ctx,
                     "Maximal count of %s for %s is %s, detected %s. Error in module %s (%s)", key, currentStatement,
                     cardinality.getMax(), value, root.rawArgument(),
-                    ctx.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, root));
+                    ctx.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, root));
             }
         }
 
@@ -164,7 +164,7 @@ public final class SubstatementValidator {
             throw new MissingSubstatementException(ctx,
                 "%s is missing %s. Minimal count is %s. Error in module %s (%s)", currentStatement, e.getKey(),
                 e.getValue().getMin(), root.rawArgument(),
-                ctx.getFromNamespace(ParserNamespaces.MODULECTX_TO_QNAME, root));
+                ctx.namespaceItem(ParserNamespaces.MODULECTX_TO_QNAME, root));
         }
     }