Remove EffectiveModelContext{Listener,Provider} 75/109575/5
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 1 Jan 2024 19:48:07 +0000 (20:48 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 2 Jan 2024 05:38:58 +0000 (06:38 +0100)
These are useless things that introduce verbosity.

At the end of the day, EffectiveModelContextProvider is someone who has

  EffectiveModelContext modelContext()

method -- which is but an idiom.

If we need to throw in a source of ISEs and callbacks, we are modeling
something much different -- better expressed explicitly where needed.

Change-Id: I6b1c11b01a0656a6a373e0d9b940607ee7a20aa0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
33 files changed:
codec/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONCodecFactory.java
codec/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONNormalizedNodeStreamWriter.java
codec/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JsonParserStream.java
codec/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/IdentityrefXmlCodec.java
codec/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/InstanceIdentifierDeserializer.java
codec/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/InstanceIdentifierXmlCodec.java
codec/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XMLStreamNormalizedNodeStreamWriter.java
codec/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlCodecFactory.java
codec/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlParserStream.java
data/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/EmptyMountPointContext.java
data/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/MountPointContext.java
data/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/SchemaOrderedNormalizedNodeWriter.java
data/yang-data-tree-api/src/main/java/org/opendaylight/yangtools/yang/data/tree/api/DataTreeSnapshot.java
data/yang-data-tree-ri/src/main/java/org/opendaylight/yangtools/yang/data/tree/impl/InMemoryDataTreeModification.java
data/yang-data-tree-ri/src/main/java/org/opendaylight/yangtools/yang/data/tree/impl/InMemoryDataTreeSnapshot.java
data/yang-data-tree-ri/src/main/java/org/opendaylight/yangtools/yang/data/tree/leafref/LeafRefContext.java
data/yang-data-tree-ri/src/main/java/org/opendaylight/yangtools/yang/data/tree/leafref/LeafRefContextBuilder.java
data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/DataSchemaContextTree.java
data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ImmutableMountPointContext.java
data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/NormalizedNodeStreamWriterStack.java
data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/XpathStringParsingPathArgumentBuilder.java
data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/codec/AbstractCodecFactory.java
data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/codec/AbstractInputStreamNormalizer.java
data/yang-data-util/src/test/java/org/opendaylight/yangtools/yang/data/util/impl/context/YT1412Test.java
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/EffectiveModelContextListener.java [deleted file]
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/EffectiveModelContextProvider.java [deleted file]
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/EffectiveStatementInference.java
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/AbstractEffectiveModelContextProvider.java [deleted file]
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/AbstractEffectiveStatementInference.java
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/DefaultSchemaTreeInference.java
model/yang-model-spi/src/test/java/org/opendaylight/yangtools/yang/model/spi/YT1414Test.java
model/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/ModuleNameNamespaceContext.java
model/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/SchemaInferenceStack.java

index b0b60c03ff5ad842a30089692d241c38091232d1..756e863e9b73af57fe16b40410eab4684f977615 100644 (file)
@@ -158,7 +158,7 @@ public abstract sealed class JSONCodecFactory extends AbstractInputStreamNormali
 
     @Override
     protected final JSONCodec<QName> identityRefCodec(final IdentityrefTypeDefinition type, final QNameModule module) {
-        return new IdentityrefJSONCodec(getEffectiveModelContext(), module);
+        return new IdentityrefJSONCodec(modelContext(), module);
     }
 
     @Override
index cb8ff42a1660c7898b6fde40ad4aaa144abbca1c..5439f14af251d0591d7464743ab5e0a534cf4dab 100644 (file)
@@ -149,8 +149,8 @@ public abstract class JSONNormalizedNodeStreamWriter implements NormalizedNodeSt
      */
     public static NormalizedNodeStreamWriter createExclusiveWriter(final JSONCodecFactory codecFactory,
             final JsonWriter jsonWriter, final @Nullable XMLNamespace initialNs) {
-        return new Exclusive(codecFactory, NormalizedNodeStreamWriterStack.of(codecFactory.getEffectiveModelContext()),
-            jsonWriter, new JSONStreamWriterExclusiveRootContext(initialNs));
+        return new Exclusive(codecFactory, NormalizedNodeStreamWriterStack.of(codecFactory.modelContext()), jsonWriter,
+            new JSONStreamWriterExclusiveRootContext(initialNs));
     }
 
     /**
@@ -203,9 +203,8 @@ public abstract class JSONNormalizedNodeStreamWriter implements NormalizedNodeSt
      */
     public static NormalizedNodeStreamWriter createExclusiveWriter(final JSONCodecFactory codecFactory,
             final Absolute path, final XMLNamespace initialNs, final JsonWriter jsonWriter) {
-        return new Exclusive(codecFactory,
-            NormalizedNodeStreamWriterStack.of(codecFactory.getEffectiveModelContext(), path), jsonWriter,
-            new JSONStreamWriterExclusiveRootContext(initialNs));
+        return new Exclusive(codecFactory, NormalizedNodeStreamWriterStack.of(codecFactory.modelContext(), path),
+            jsonWriter, new JSONStreamWriterExclusiveRootContext(initialNs));
     }
 
     /**
@@ -250,8 +249,8 @@ public abstract class JSONNormalizedNodeStreamWriter implements NormalizedNodeSt
      */
     public static NormalizedNodeStreamWriter createNestedWriter(final JSONCodecFactory codecFactory,
             final JsonWriter jsonWriter, final @Nullable XMLNamespace initialNs) {
-        return new Nested(codecFactory, NormalizedNodeStreamWriterStack.of(codecFactory.getEffectiveModelContext()),
-            jsonWriter, new JSONStreamWriterSharedRootContext(initialNs));
+        return new Nested(codecFactory, NormalizedNodeStreamWriterStack.of(codecFactory.modelContext()), jsonWriter,
+            new JSONStreamWriterSharedRootContext(initialNs));
     }
 
     /**
@@ -275,9 +274,8 @@ public abstract class JSONNormalizedNodeStreamWriter implements NormalizedNodeSt
      */
     public static NormalizedNodeStreamWriter createNestedWriter(final JSONCodecFactory codecFactory,
             final Absolute path, final XMLNamespace initialNs, final JsonWriter jsonWriter) {
-        return new Nested(codecFactory,
-            NormalizedNodeStreamWriterStack.of(codecFactory.getEffectiveModelContext(), path), jsonWriter,
-            new JSONStreamWriterSharedRootContext(initialNs));
+        return new Nested(codecFactory, NormalizedNodeStreamWriterStack.of(codecFactory.modelContext(), path),
+            jsonWriter, new JSONStreamWriterSharedRootContext(initialNs));
     }
 
     /**
@@ -313,8 +311,8 @@ public abstract class JSONNormalizedNodeStreamWriter implements NormalizedNodeSt
     @Override
     public void startLeafNode(final NodeIdentifier name) throws IOException {
         tracker.startLeafNode(name);
-        context.emittingChild(codecs.getEffectiveModelContext(), writer);
-        context.writeChildJsonIdentifier(codecs.getEffectiveModelContext(), writer, name.getNodeType());
+        context.emittingChild(codecs.modelContext(), writer);
+        context.writeChildJsonIdentifier(codecs.modelContext(), writer, name.getNodeType());
     }
 
     @Override
@@ -326,7 +324,7 @@ public abstract class JSONNormalizedNodeStreamWriter implements NormalizedNodeSt
     @Override
     public void startLeafSetEntryNode(final NodeWithValue<?> name) throws IOException {
         tracker.startLeafSetEntryNode(name);
-        context.emittingChild(codecs.getEffectiveModelContext(), writer);
+        context.emittingChild(codecs.modelContext(), writer);
     }
 
     @Override
@@ -387,8 +385,8 @@ public abstract class JSONNormalizedNodeStreamWriter implements NormalizedNodeSt
     public final boolean startAnydataNode(final NodeIdentifier name, final Class<?> objectModel) throws IOException {
         if (NormalizedAnydata.class.isAssignableFrom(objectModel)) {
             tracker.startAnydataNode(name);
-            context.emittingChild(codecs.getEffectiveModelContext(), writer);
-            context.writeChildJsonIdentifier(codecs.getEffectiveModelContext(), writer, name.getNodeType());
+            context.emittingChild(codecs.modelContext(), writer);
+            context.writeChildJsonIdentifier(codecs.modelContext(), writer, name.getNodeType());
             return true;
         }
 
@@ -398,7 +396,7 @@ public abstract class JSONNormalizedNodeStreamWriter implements NormalizedNodeSt
     @Override
     public final NormalizedNodeStreamWriter startMountPoint(final MountPointLabel label,
             final MountPointContext mountCtx) throws IOException {
-        final EffectiveModelContext ctx = mountCtx.getEffectiveModelContext();
+        final EffectiveModelContext ctx = mountCtx.modelContext();
         return new Nested(codecs.rebaseTo(ctx), NormalizedNodeStreamWriterStack.of(ctx), writer,
             new JSONStreamWriterSharedRootContext(context.getNamespace()));
     }
@@ -407,8 +405,8 @@ public abstract class JSONNormalizedNodeStreamWriter implements NormalizedNodeSt
     public final boolean startAnyxmlNode(final NodeIdentifier name, final Class<?> objectModel) throws IOException {
         if (DOMSource.class.isAssignableFrom(objectModel)) {
             tracker.startAnyxmlNode(name);
-            context.emittingChild(codecs.getEffectiveModelContext(), writer);
-            context.writeChildJsonIdentifier(codecs.getEffectiveModelContext(), writer, name.getNodeType());
+            context.emittingChild(codecs.modelContext(), writer);
+            context.writeChildJsonIdentifier(codecs.modelContext(), writer, name.getNodeType());
             return true;
         }
         return false;
@@ -417,7 +415,7 @@ public abstract class JSONNormalizedNodeStreamWriter implements NormalizedNodeSt
     @Override
     public final void endNode() throws IOException {
         tracker.endNode();
-        context = context.endNode(codecs.getEffectiveModelContext(), writer);
+        context = context.endNode(codecs.modelContext(), writer);
     }
 
     @Override
@@ -430,7 +428,7 @@ public abstract class JSONNormalizedNodeStreamWriter implements NormalizedNodeSt
             throw new IOException("Unexpected root context " + context);
         }
 
-        context.endNode(codecs.getEffectiveModelContext(), writer);
+        context.endNode(codecs.modelContext(), writer);
         writer.close();
     }
 
@@ -479,7 +477,7 @@ public abstract class JSONNormalizedNodeStreamWriter implements NormalizedNodeSt
         }
 
         anydata.writeTo(JSONNormalizedNodeStreamWriter.createNestedWriter(
-            codecs.rebaseTo(inference.getEffectiveModelContext()), inference, context.getNamespace(), writer));
+            codecs.rebaseTo(inference.modelContext()), inference, context.getNamespace(), writer));
     }
 
     private void writeAnyXmlValue(final DOMSource anyXmlValue) throws IOException {
index 1b5ac3b99175421fb489330ef806850a7e05ca8a..4d6ffc7270df79df4fb66bf142835c4c652ad15a 100644 (file)
@@ -94,7 +94,7 @@ public final class JsonParserStream implements Closeable, Flushable {
                 throw new IllegalArgumentException("Illegal parent node " + parent);
             }
         } else {
-            parentNode = stack.getEffectiveModelContext();
+            parentNode = stack.modelContext();
         }
     }
 
@@ -111,7 +111,7 @@ public final class JsonParserStream implements Closeable, Flushable {
     public static @NonNull JsonParserStream create(final @NonNull NormalizedNodeStreamWriter writer,
             final @NonNull JSONCodecFactory codecFactory) {
         return new JsonParserStream(writer, codecFactory,
-            SchemaInferenceStack.of(codecFactory.getEffectiveModelContext()), false);
+            SchemaInferenceStack.of(codecFactory.modelContext()), false);
     }
 
     /**
@@ -148,7 +148,7 @@ public final class JsonParserStream implements Closeable, Flushable {
     public static @NonNull JsonParserStream createLenient(final @NonNull NormalizedNodeStreamWriter writer,
             final @NonNull JSONCodecFactory codecFactory) {
         return new JsonParserStream(writer, codecFactory,
-            SchemaInferenceStack.of(codecFactory.getEffectiveModelContext()), true);
+            SchemaInferenceStack.of(codecFactory.modelContext()), true);
     }
 
     /**
@@ -384,7 +384,7 @@ public final class JsonParserStream implements Closeable, Flushable {
             final var moduleNamePart = childName.substring(0, lastIndexOfColon);
             nodeNamePart = childName.substring(lastIndexOfColon + 1);
 
-            final var m = codecs.getEffectiveModelContext().findModuleStatements(moduleNamePart).iterator();
+            final var m = codecs.modelContext().findModuleStatements(moduleNamePart).iterator();
             namespace = m.hasNext() ? m.next().localQNameModule().getNamespace() : null;
         } else {
             nodeNamePart = childName;
@@ -414,7 +414,7 @@ public final class JsonParserStream implements Closeable, Flushable {
         for (var potentialUri : potentialUris) {
             sb.append('\n');
             // FIXME how to get information about revision from JSON input? currently first available is used.
-            sb.append(codecs.getEffectiveModelContext().findModuleStatements(potentialUri).iterator().next()
+            sb.append(codecs.modelContext().findModuleStatements(potentialUri).iterator().next()
                 .argument().getLocalName());
         }
         return sb.toString();
index 06430a18529230877dcfe1894ede85f19eb7ba27..ed6caa63dd454b3bd8a7d83efc10bf5513da8265 100644 (file)
@@ -24,13 +24,13 @@ import org.opendaylight.yangtools.yang.data.util.codec.QNameCodecUtil;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
 final class IdentityrefXmlCodec implements XmlCodec<QName> {
-    private final @NonNull EffectiveModelContext context;
+    private final @NonNull EffectiveModelContext modelContext;
     private final @NonNull QNameModule parentModule;
     private final @Nullable PreferredPrefixes pref;
 
-    IdentityrefXmlCodec(final EffectiveModelContext context, final QNameModule parentModule,
+    IdentityrefXmlCodec(final EffectiveModelContext modelContext, final QNameModule parentModule,
             final @Nullable PreferredPrefixes pref) {
-        this.context = requireNonNull(context);
+        this.modelContext = requireNonNull(modelContext);
         this.parentModule = requireNonNull(parentModule);
         this.pref = pref;
     }
@@ -42,7 +42,7 @@ final class IdentityrefXmlCodec implements XmlCodec<QName> {
 
     @Override
     public QName parseValue(final NamespaceContext ctx, final String str) {
-        return IdentityCodecUtil.parseIdentity(str, context, prefix -> {
+        return IdentityCodecUtil.parseIdentity(str, modelContext, prefix -> {
             if (prefix.isEmpty()) {
                 return parentModule;
             }
@@ -50,7 +50,7 @@ final class IdentityrefXmlCodec implements XmlCodec<QName> {
             final var prefixedNS = ctx.getNamespaceURI(prefix);
             checkArgument(prefixedNS != null, "Failed to resolve prefix %s", prefix);
 
-            final var modules = context.findModuleStatements(XMLNamespace.of(prefixedNS)).iterator();
+            final var modules = modelContext.findModuleStatements(XMLNamespace.of(prefixedNS)).iterator();
             checkArgument(modules.hasNext(), "Could not find module for namespace %s", prefixedNS);
             return modules.next().localQNameModule();
         }).getQName();
index fcd02a4c0151adbbebcf207484186ecc03618c06..973290b9c97be2f669c96f61ca3ac1fca984f071 100644 (file)
@@ -32,7 +32,7 @@ final class InstanceIdentifierDeserializer extends AbstractInstanceIdentifierCod
 
     @Override
     protected QNameModule moduleForPrefix(final String prefix) {
-        final var modules = codecFactory.getEffectiveModelContext()
+        final var modules = codecFactory.modelContext()
             .findModuleStatements(XMLNamespace.of(namespaceContext.getNamespaceURI(prefix)))
             .iterator();
         return modules.hasNext() ? modules.next().localQNameModule() : null;
index 1ce6d6c456f6e460f1d2f005326286f5041299ef..23214b0429bbc7be55a660fdf7a2d68ff41469ff 100644 (file)
@@ -25,7 +25,7 @@ final class InstanceIdentifierXmlCodec implements XmlCodec<YangInstanceIdentifie
     InstanceIdentifierXmlCodec(final XmlCodecFactory codecFactory, final @Nullable PreferredPrefixes pref) {
         this.codecFactory = requireNonNull(codecFactory);
         this.pref = pref;
-        dataContextTree = DataSchemaContextTree.from(codecFactory.getEffectiveModelContext());
+        dataContextTree = DataSchemaContextTree.from(codecFactory.modelContext());
     }
 
     @Override
index e8f9149dd9119df4765c9c7a558a970a2554f1db..8dfa36f98686e99ee401c3cf9fdecd0e01f7a56b 100644 (file)
@@ -110,7 +110,7 @@ public abstract sealed class XMLStreamNormalizedNodeStreamWriter<T>
      */
     public static @NonNull NormalizedNodeStreamWriter create(final XMLStreamWriter writer,
             final EffectiveStatementInference inference, final boolean preferPrefixes) {
-        return new SchemaAwareXMLStreamNormalizedNodeStreamWriter(writer, inference.getEffectiveModelContext(),
+        return new SchemaAwareXMLStreamNormalizedNodeStreamWriter(writer, inference.modelContext(),
             NormalizedNodeStreamWriterStack.of(inference), preferPrefixes);
     }
 
index ab465a2376754a2b416227f2f46413e54b9eb9db..43ec7fe516c0317db2001918281010698bb77ddb 100644 (file)
@@ -54,9 +54,9 @@ public final class XmlCodecFactory extends AbstractCodecFactory<XmlCodec<?>> {
     private final @Nullable PreferredPrefixes pref;
 
     private XmlCodecFactory(final MountPointContext mountCtx, final boolean modelPrefixes) {
-        super(mountCtx.getEffectiveModelContext(), new SharedCodecCache<>());
+        super(mountCtx.modelContext(), new SharedCodecCache<>());
         this.mountCtx = requireNonNull(mountCtx);
-        pref = modelPrefixes ? new PreferredPrefixes.Shared(getEffectiveModelContext()) : null;
+        pref = modelPrefixes ? new PreferredPrefixes.Shared(modelContext()) : null;
         instanceIdentifierCodec = new InstanceIdentifierXmlCodec(this, pref);
     }
 
@@ -133,7 +133,7 @@ public final class XmlCodecFactory extends AbstractCodecFactory<XmlCodec<?>> {
 
     @Override
     protected XmlCodec<?> identityRefCodec(final IdentityrefTypeDefinition type, final QNameModule module) {
-        return new IdentityrefXmlCodec(getEffectiveModelContext(), module, pref);
+        return new IdentityrefXmlCodec(modelContext(), module, pref);
     }
 
     @Override
index a5b161f8058391ac665f8370d179e2c465a261fc..15fc6d6274bee60c47a37f6ac24f3fd6b21c3845 100644 (file)
@@ -162,7 +162,7 @@ public final class XmlParserStream implements Closeable, Flushable {
                 throw new IllegalArgumentException("Illegal parent node " + stmt);
             }
         } else {
-            parentNode = stack.getEffectiveModelContext();
+            parentNode = stack.modelContext();
         }
     }
 
@@ -233,7 +233,7 @@ public final class XmlParserStream implements Closeable, Flushable {
      */
     public static XmlParserStream create(final NormalizedNodeStreamWriter writer,
             final EffectiveStatementInference parentNode, final boolean strictParsing) {
-        return create(writer, XmlCodecFactory.create(parentNode.getEffectiveModelContext()), parentNode, strictParsing);
+        return create(writer, XmlCodecFactory.create(parentNode.modelContext()), parentNode, strictParsing);
     }
 
     /**
@@ -242,8 +242,7 @@ public final class XmlParserStream implements Closeable, Flushable {
      * instead and maintain a {@link XmlCodecFactory} to match the current {@link MountPointContext}.
      */
     public static XmlParserStream create(final NormalizedNodeStreamWriter writer, final MountPointContext mountCtx) {
-        return create(writer, mountCtx, SchemaInferenceStack.of(mountCtx.getEffectiveModelContext()).toInference(),
-            true);
+        return create(writer, mountCtx, SchemaInferenceStack.of(mountCtx.modelContext()).toInference(), true);
     }
 
     /**
@@ -278,7 +277,7 @@ public final class XmlParserStream implements Closeable, Flushable {
     public static XmlParserStream create(final NormalizedNodeStreamWriter writer, final XmlCodecFactory codecs,
             final Absolute parentNode, final boolean strictParsing) {
         return new XmlParserStream(writer, codecs,
-            SchemaInferenceStack.of(codecs.getEffectiveModelContext(), parentNode), strictParsing);
+            SchemaInferenceStack.of(codecs.modelContext(), parentNode), strictParsing);
     }
 
     @Beta
@@ -290,7 +289,7 @@ public final class XmlParserStream implements Closeable, Flushable {
     @Beta
     public static XmlParserStream create(final NormalizedNodeStreamWriter writer, final MountPointContext mountCtx,
             final YangInstanceIdentifier parentNode, final boolean strictParsing) {
-        final var init = DataSchemaContextTree.from(mountCtx.getEffectiveModelContext())
+        final var init = DataSchemaContextTree.from(mountCtx.modelContext())
             .enterPath(parentNode)
             .orElseThrow();
         return new XmlParserStream(writer, XmlCodecFactory.create(mountCtx), init.stack(), strictParsing);
@@ -372,7 +371,7 @@ public final class XmlParserStream implements Closeable, Flushable {
             final Optional<QNameModule> optModule = resolveXmlNamespace(attributeNS);
             if (optModule.isPresent()) {
                 final QName qname = QName.create(optModule.orElseThrow(), localName);
-                final var optAnnotation = AnnotationSchemaNode.find(codecs.getEffectiveModelContext(),
+                final var optAnnotation = AnnotationSchemaNode.find(codecs.modelContext(),
                     new AnnotationName(qname));
                 if (optAnnotation.isPresent()) {
                     final AnnotationSchemaNode schema = optAnnotation.orElseThrow();
@@ -711,7 +710,7 @@ public final class XmlParserStream implements Closeable, Flushable {
 
     private Optional<QNameModule> resolveXmlNamespace(final String xmlNamespace) {
         return resolvedNamespaces.computeIfAbsent(xmlNamespace, nsUri -> {
-            final var it = codecs.getEffectiveModelContext().findModuleStatements(XMLNamespace.of(nsUri)).iterator();
+            final var it = codecs.modelContext().findModuleStatements(XMLNamespace.of(nsUri)).iterator();
             return it.hasNext() ? Optional.of(it.next().localQNameModule()) : Optional.empty();
         });
     }
index 33a33a52cdb8cba56c9d64ef98fb1fc51e234ccc..90cd62e50b39fdca5171358ec40f398f197d6ff1 100644 (file)
@@ -7,17 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.data.api.schema;
 
+import static java.util.Objects.requireNonNull;
+
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.MountPointLabel;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.spi.AbstractEffectiveModelContextProvider;
 
 /**
  * A simple {@link MountPointContext} which does not contain any mount points.
  */
-final class EmptyMountPointContext extends AbstractEffectiveModelContextProvider implements MountPointContext {
-    EmptyMountPointContext(final EffectiveModelContext modelContext) {
-        super(modelContext);
+record EmptyMountPointContext(@NonNull EffectiveModelContext modelContext) implements MountPointContext {
+    EmptyMountPointContext {
+        requireNonNull(modelContext);
     }
 
     @Override
index 0086d8730f6010179f6a44c810686147414e6def..da30b382ebaa9391e9447415d1d87f0f99302937 100644 (file)
@@ -11,7 +11,6 @@ import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.MountPointLabel;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
 
 /**
  * A context of either an explicit (RFC8528 Schema Mount instance) or implicit (system root). It encapsulates a data
@@ -23,7 +22,14 @@ import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
  * so that proper {@link MountPointLabel}ed {@link NormalizedMountPoint}s can be created. This is enough to integrate
  * with other elements of this API.
  */
-public interface MountPointContext extends EffectiveModelContextProvider {
+public interface MountPointContext {
+    /**
+     * Return this mount point's {@link EffectiveModelContext}.
+     *
+     * @return this mount point's {@link EffectiveModelContext}
+     */
+    @NonNull EffectiveModelContext modelContext();
+
     /**
      * Attempt to acquire a {@link MountPointContextFactory} to resolve schemas for the purposes of interpreting
      * this mount point. An empty result indicates the mount point is not attached.
index c8e526b2ad724c3e02596830cf1dde6dccc9e33d..c1c63711a8d57445640e6538d007ad06070174a7 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
-import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.ArrayListMultimap;
@@ -19,15 +18,12 @@ import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaTreeInference;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
 
@@ -36,7 +32,7 @@ import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
  * in the order as they are defined in YANG file.
  */
 public class SchemaOrderedNormalizedNodeWriter extends NormalizedNodeWriter {
-    private final EffectiveModelContext schemaContext;
+    private final EffectiveModelContext modelContext;
     private final SchemaNode root;
 
     private SchemaNode currentSchemaNode;
@@ -45,26 +41,29 @@ public class SchemaOrderedNormalizedNodeWriter extends NormalizedNodeWriter {
      * Create a new writer backed by a {@link NormalizedNodeStreamWriter}.
      *
      * @param writer Back-end writer
-     * @param schemaContext Associated {@link EffectiveModelContext}
+     * @param modelContext Associated {@link EffectiveModelContext}
      */
     public SchemaOrderedNormalizedNodeWriter(final NormalizedNodeStreamWriter writer,
-            final EffectiveModelContext schemaContext) {
+            final EffectiveModelContext modelContext) {
         super(writer);
-        root = this.schemaContext = requireNonNull(schemaContext);
+        root = this.modelContext = requireNonNull(modelContext);
     }
 
     private SchemaOrderedNormalizedNodeWriter(final NormalizedNodeStreamWriter writer,
             final SchemaInferenceStack stack) {
         super(writer);
-        schemaContext = stack.getEffectiveModelContext();
+        modelContext = stack.modelContext();
 
         if (!stack.isEmpty()) {
-            final EffectiveStatement<?, ?> current = stack.currentStatement();
+            final var current = stack.currentStatement();
             // FIXME: this should be one of NormalizedNodeContainer/NotificationDefinition/OperationDefinition
-            checkArgument(current instanceof SchemaNode, "Instantiating at %s is not supported", current);
-            root = (SchemaNode) current;
+            if (current instanceof SchemaNode schemaNode) {
+                root = schemaNode;
+            } else {
+                throw new IllegalArgumentException("Instantiating at " + current + " is not supported");
+            }
         } else {
-            root = schemaContext;
+            root = modelContext;
         }
     }
 
@@ -93,8 +92,8 @@ public class SchemaOrderedNormalizedNodeWriter extends NormalizedNodeWriter {
 
     @Override
     public SchemaOrderedNormalizedNodeWriter write(final NormalizedNode node) throws IOException {
-        if (schemaContext.equals(root)) {
-            currentSchemaNode = schemaContext.dataChildByName(node.name().getNodeType());
+        if (modelContext.equals(root)) {
+            currentSchemaNode = modelContext.dataChildByName(node.name().getNodeType());
         } else {
             currentSchemaNode = root;
         }
@@ -122,7 +121,7 @@ public class SchemaOrderedNormalizedNodeWriter extends NormalizedNodeWriter {
             throws IOException {
 
         //Set current schemaNode
-        try (SchemaNodeSetter sns = new SchemaNodeSetter(dataSchemaNode)) {
+        try (var sns = new SchemaNodeSetter(dataSchemaNode)) {
             if (node == null) {
                 return this;
             }
@@ -140,7 +139,7 @@ public class SchemaOrderedNormalizedNodeWriter extends NormalizedNodeWriter {
     }
 
     private void write(final Collection<NormalizedNode> nodes, final SchemaNode dataSchemaNode) throws IOException {
-        for (final NormalizedNode node : nodes) {
+        for (var node : nodes) {
             write(node, dataSchemaNode);
         }
     }
@@ -154,7 +153,7 @@ public class SchemaOrderedNormalizedNodeWriter extends NormalizedNodeWriter {
             final boolean endParent) throws IOException {
         // Augmentations cannot be gotten with node.getChild so create our own structure with augmentations resolved
         final var qnameToNodes = ArrayListMultimap.<QName, NormalizedNode>create();
-        for (final NormalizedNode child : children) {
+        for (var child : children) {
             putChild(qnameToNodes, child);
         }
 
@@ -162,20 +161,21 @@ public class SchemaOrderedNormalizedNodeWriter extends NormalizedNodeWriter {
             if (parentContainer instanceof ListSchemaNode && qnameToNodes.containsKey(parentSchemaNode.getQName())) {
                 write(qnameToNodes.get(parentSchemaNode.getQName()), parentSchemaNode);
             } else {
-                for (final DataSchemaNode schemaNode : parentContainer.getChildNodes()) {
+                for (var schemaNode : parentContainer.getChildNodes()) {
                     write(qnameToNodes.get(schemaNode.getQName()), schemaNode);
                 }
             }
         } else if (parentSchemaNode instanceof ChoiceSchemaNode parentChoice) {
-            for (final CaseSchemaNode ccNode : parentChoice.getCases()) {
-                for (final DataSchemaNode dsn : ccNode.getChildNodes()) {
-                    if (qnameToNodes.containsKey(dsn.getQName())) {
-                        write(qnameToNodes.get(dsn.getQName()), dsn);
+            for (var childCase : parentChoice.getCases()) {
+                for (var childCaseChild : childCase.getChildNodes()) {
+                    final var node = qnameToNodes.asMap().get(childCaseChild.getQName());
+                    if (node != null) {
+                        write(node, childCaseChild);
                     }
                 }
             }
         } else {
-            for (final NormalizedNode child : children) {
+            for (var child : children) {
                 writeLeaf(child);
             }
         }
index 2e907ea769e4a3d238321ef259ffd8a77cd5d2da..9cb505159ed5b0aa5e8b56e34bad20d83b3b858d 100644 (file)
@@ -11,13 +11,20 @@ import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
 /**
  * Read-only snapshot of a {@link DataTree}. The snapshot is stable and isolated, e.g. data tree changes occurring after
  * the snapshot has been taken are not visible through the snapshot.
  */
-public interface DataTreeSnapshot extends EffectiveModelContextProvider {
+public interface DataTreeSnapshot {
+    /**
+     * Return the {@link EffectiveModelContext} effective at the time this snapshot was taken.
+     *
+     * @return the {@link EffectiveModelContext} effective at the time this snapshot was taken
+     */
+    @NonNull EffectiveModelContext modelContext();
+
     /**
      * Read a particular node from the snapshot.
      *
@@ -27,8 +34,7 @@ public interface DataTreeSnapshot extends EffectiveModelContextProvider {
     Optional<NormalizedNode> readNode(YangInstanceIdentifier path);
 
     /**
-     * Create a new data tree modification based on this snapshot, using the
-     * specified data application strategy.
+     * Create a new data tree modification based on this snapshot, using the specified data application strategy.
      *
      * @return A new data tree modification
      */
index f3fa3af10e7fd685e1c4b312e4b62ed791c6b162..6607027197e2c9238143f829a47bbdc231582ed0 100644 (file)
@@ -27,12 +27,10 @@ import org.opendaylight.yangtools.yang.data.tree.api.SchemaValidationFailedExcep
 import org.opendaylight.yangtools.yang.data.tree.impl.node.TreeNode;
 import org.opendaylight.yangtools.yang.data.tree.impl.node.Version;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-final class InMemoryDataTreeModification extends AbstractCursorAware implements CursorAwareDataTreeModification,
-        EffectiveModelContextProvider {
+final class InMemoryDataTreeModification extends AbstractCursorAware implements CursorAwareDataTreeModification {
     private static final Logger LOG = LoggerFactory.getLogger(InMemoryDataTreeModification.class);
 
     private static final byte STATE_OPEN    = 0;
@@ -90,8 +88,8 @@ final class InMemoryDataTreeModification extends AbstractCursorAware implements
     }
 
     @Override
-    public EffectiveModelContext getEffectiveModelContext() {
-        return snapshot.getEffectiveModelContext();
+    public EffectiveModelContext modelContext() {
+        return snapshot.modelContext();
     }
 
     @Override
@@ -214,8 +212,7 @@ final class InMemoryDataTreeModification extends AbstractCursorAware implements
         if (newRoot == null) {
             throw new IllegalStateException("Data tree root is not present, possibly removed by previous modification");
         }
-        return new InMemoryDataTreeSnapshot(snapshot.getEffectiveModelContext(), newRoot, strategyTree)
-            .newModification();
+        return new InMemoryDataTreeSnapshot(snapshot.modelContext(), newRoot, strategyTree).newModification();
     }
 
     Version getVersion() {
index f058d6317d92ee0f4106008ad35dbfa1f5784213..f6fc474054250a2fb6c875f200669c75ee7f10c3 100644 (file)
@@ -20,17 +20,15 @@ import org.opendaylight.yangtools.yang.data.tree.api.CursorAwareDataTreeSnapshot
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshotCursor;
 import org.opendaylight.yangtools.yang.data.tree.impl.node.TreeNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
 
-final class InMemoryDataTreeSnapshot extends AbstractCursorAware implements CursorAwareDataTreeSnapshot,
-        EffectiveModelContextProvider {
+final class InMemoryDataTreeSnapshot extends AbstractCursorAware implements CursorAwareDataTreeSnapshot {
+    private final @NonNull EffectiveModelContext modelContext;
     private final @NonNull RootApplyStrategy applyOper;
-    private final @NonNull EffectiveModelContext schemaContext;
     private final @NonNull TreeNode rootNode;
 
-    InMemoryDataTreeSnapshot(final EffectiveModelContext schemaContext, final TreeNode rootNode,
+    InMemoryDataTreeSnapshot(final EffectiveModelContext modelContext, final TreeNode rootNode,
             final RootApplyStrategy applyOper) {
-        this.schemaContext = requireNonNull(schemaContext);
+        this.modelContext = requireNonNull(modelContext);
         this.rootNode = requireNonNull(rootNode);
         this.applyOper = requireNonNull(applyOper);
     }
@@ -40,8 +38,8 @@ final class InMemoryDataTreeSnapshot extends AbstractCursorAware implements Curs
     }
 
     @Override
-    public EffectiveModelContext getEffectiveModelContext() {
-        return schemaContext;
+    public EffectiveModelContext modelContext() {
+        return modelContext;
     }
 
     @Override
index 00efedf3485f433e0a60d2ca51109dd474b8d251..6aa8f3a822cab3c8f057870c8a6d272aa7abcb9e 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.data.tree.leafref;
 
 import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.Beta;
 import com.google.common.collect.ImmutableList;
@@ -17,13 +18,14 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
-import org.opendaylight.yangtools.yang.model.spi.AbstractEffectiveModelContextProvider;
 
-public final class LeafRefContext extends AbstractEffectiveModelContextProvider {
+public final class LeafRefContext {
+    private final @NonNull EffectiveModelContext modelContext;
 
     private final QName currentNodeQName;
     private final ImmutableList<QName> currentNodePath;
@@ -46,7 +48,7 @@ public final class LeafRefContext extends AbstractEffectiveModelContextProvider
     private volatile LeafRefPath leafRefNodePath = null;
 
     LeafRefContext(final LeafRefContextBuilder leafRefContextBuilder) {
-        super(leafRefContextBuilder.getSchemaContext());
+        modelContext = requireNonNull(leafRefContextBuilder.modelContext());
         currentNodeQName = leafRefContextBuilder.getCurrentNodeQName();
         currentNodePath = leafRefContextBuilder.getCurrentNodePath();
         leafRefTargetPath = leafRefContextBuilder.getLeafRefTargetPath();
@@ -60,6 +62,15 @@ public final class LeafRefContext extends AbstractEffectiveModelContextProvider
         module = leafRefContextBuilder.getLeafRefContextModule();
     }
 
+    /**
+     * Return the {@link EffectiveModelContext} from which this context was derived.
+     *
+     * @return the {@link EffectiveModelContext} from which this context was derived
+     */
+    public @NonNull EffectiveModelContext modelContext() {
+        return modelContext;
+    }
+
     public static LeafRefContext create(final EffectiveModelContext ctx) {
         return new LeafRefContextTreeBuilder(ctx).buildLeafRefContextTree();
     }
@@ -167,9 +178,7 @@ public final class LeafRefContext extends AbstractEffectiveModelContextProvider
     private Iterator<QName> descendantIterator(final SchemaNodeIdentifier node) {
         final Iterator<QName> nodeSteps = node.getNodeIdentifiers().iterator();
         if (node instanceof SchemaNodeIdentifier.Absolute) {
-            final Iterator<QName> mySteps = currentNodePath.iterator();
-            while (mySteps.hasNext()) {
-                final QName myNext = mySteps.next();
+            for (QName myNext : currentNodePath) {
                 checkArgument(nodeSteps.hasNext(), "Node %s is an ancestor of %s", node, currentNodePath);
                 final QName nodeNext = nodeSteps.next();
                 checkArgument(myNext.equals(nodeNext), "Node %s is not a descendant of %s", node, currentNodePath);
index 08cee01dee820a4ce32b274c379619fd8a544571..ce7ef3dbaf6e0630bddf76c8107cd29b510435dd 100644 (file)
@@ -26,7 +26,7 @@ final class LeafRefContextBuilder implements Mutable {
 
     private final QName currentNodeQName;
     private final ImmutableList<QName> currentNodePath;
-    private final EffectiveModelContext schemaContext;
+    private final EffectiveModelContext modelContext;
 
     private LeafRefPath leafRefTargetPath = null;
     private LeafRefPath absoluteLeafRefTargetPath = null;
@@ -36,10 +36,10 @@ final class LeafRefContextBuilder implements Mutable {
     private boolean isReferencing = false;
 
     LeafRefContextBuilder(final QName currentNodeQName, final ImmutableList<QName> currentNodePath,
-            final EffectiveModelContext schemaContext) {
+            final EffectiveModelContext modelContext) {
         this.currentNodeQName = requireNonNull(currentNodeQName);
         this.currentNodePath = requireNonNull(currentNodePath);
-        this.schemaContext = requireNonNull(schemaContext);
+        this.modelContext = requireNonNull(modelContext);
     }
 
     @NonNull LeafRefContext build() {
@@ -109,8 +109,8 @@ final class LeafRefContextBuilder implements Mutable {
         return currentNodeQName;
     }
 
-    EffectiveModelContext getSchemaContext() {
-        return schemaContext;
+    EffectiveModelContext modelContext() {
+        return modelContext;
     }
 
     LeafRefPath getAbsoluteLeafRefTargetPath() {
@@ -129,7 +129,7 @@ final class LeafRefContextBuilder implements Mutable {
     Module getLeafRefContextModule() {
         final QNameModule qnameModule = currentNodePath.isEmpty() ? currentNodeQName.getModule()
             : currentNodePath.get(0).getModule();
-        return schemaContext.findModule(qnameModule).orElse(null);
+        return modelContext.findModule(qnameModule).orElse(null);
     }
 
     void addReferencedByLeafRefCtx(final QName qname, final LeafRefContext leafRef) {
index 05a415cfc59f0763f611bc729e5bae501467ec0d..4785086c496590568d48b5981c0930bbd2949a1e 100644 (file)
@@ -21,14 +21,13 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContext.Composite;
 import org.opendaylight.yangtools.yang.data.util.impl.context.ContainerContext;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.spi.AbstractEffectiveModelContextProvider;
 import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
 
 /**
  * Semantic tree binding a {@link EffectiveModelContext} to a {@link NormalizedNode} tree. Since the layout of the
  * schema and data has differences, the mapping is not trivial -- which is where this class comes in.
  */
-public final class DataSchemaContextTree extends AbstractEffectiveModelContextProvider {
+public final class DataSchemaContextTree {
     public record NodeAndStack(@NonNull DataSchemaContext node, @NonNull SchemaInferenceStack stack) {
         public NodeAndStack(final @NonNull DataSchemaContext node, final @NonNull SchemaInferenceStack stack) {
             this.node = requireNonNull(node);
@@ -44,17 +43,27 @@ public final class DataSchemaContextTree extends AbstractEffectiveModelContextPr
             }
         });
 
+    private final @NonNull EffectiveModelContext modelContext;
     private final @NonNull ContainerContext root;
 
-    private DataSchemaContextTree(final EffectiveModelContext ctx) {
-        super(ctx);
-        root = new ContainerContext(ctx);
+    private DataSchemaContextTree(final EffectiveModelContext modelContext) {
+        this.modelContext = requireNonNull(modelContext);
+        root = new ContainerContext(modelContext);
     }
 
     public static @NonNull DataSchemaContextTree from(final @NonNull EffectiveModelContext ctx) {
         return TREES.getUnchecked(ctx);
     }
 
+    /**
+     * Return the {@link EffectiveModelContext} used to derive this tree.
+     *
+     * @return the {@link EffectiveModelContext} used to derive this tree
+     */
+    public @NonNull EffectiveModelContext modelContext() {
+        return modelContext;
+    }
+
     /**
      * Find a child node as identified by an absolute {@link YangInstanceIdentifier}.
      *
index 671d2f4075d36540eb12c67a5ba251f95675cc1b..2c2f7f63cf6b2af8d78bb150b2f5d7705e09dc0b 100644 (file)
@@ -9,40 +9,38 @@ package org.opendaylight.yangtools.yang.data.util;
 
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Maps;
 import java.util.Optional;
 import java.util.function.Function;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.common.MountPointLabel;
 import org.opendaylight.yangtools.yang.data.api.schema.MountPointContext;
 import org.opendaylight.yangtools.yang.data.api.schema.MountPointContextFactory;
 import org.opendaylight.yangtools.yang.data.util.AbstractMountPointContextFactory.MountPointDefinition;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.spi.AbstractEffectiveModelContextProvider;
 
-final class ImmutableMountPointContext extends AbstractEffectiveModelContextProvider
+record ImmutableMountPointContext(
+        @NonNull EffectiveModelContext modelContext,
+        @NonNull ImmutableMap<MountPointLabel, MountPointDefinition> mountPoints,
+        @NonNull Function<MountPointDefinition, MountPointContextFactory> createFactory)
         implements Immutable, MountPointContext {
-    private final ImmutableMap<MountPointLabel, MountPointDefinition> mountPoints;
-    private final Function<MountPointDefinition, MountPointContextFactory> createFactory;
+    ImmutableMountPointContext {
+        requireNonNull(modelContext);
+        requireNonNull(mountPoints);
+        requireNonNull(createFactory);
+    }
 
     ImmutableMountPointContext(final EffectiveModelContext modelContext,
             final Iterable<MountPointDefinition> mountPoints,
             final Function<MountPointDefinition, MountPointContextFactory> createFactory) {
-        super(modelContext);
-        this.mountPoints = Maps.uniqueIndex(mountPoints, MountPointDefinition::label);
-        this.createFactory = requireNonNull(createFactory);
+        this(modelContext, Maps.uniqueIndex(mountPoints, MountPointDefinition::label), createFactory);
     }
 
     @Override
     public Optional<MountPointContextFactory> findMountPoint(final MountPointLabel label) {
-        final MountPointDefinition def = mountPoints.get(requireNonNull(label));
+        final var def = mountPoints.get(requireNonNull(label));
         return def == null ? Optional.empty() : Optional.of(createFactory.apply(def));
     }
-
-    @Override
-    protected ToStringHelper addToStringAttributes(final ToStringHelper helper) {
-        return super.addToStringAttributes(helper).add("mountPoints", mountPoints);
-    }
 }
index 72547fe4285f769da454aa2bd8dc5ff476bb805b..c03aae08a55d23dd326fe4091029d577b7615ba9 100644 (file)
@@ -76,7 +76,7 @@ public final class NormalizedNodeStreamWriterStack implements LeafrefResolver {
                 throw new IllegalArgumentException("Cannot instantiate on " + current);
             }
         } else {
-            root = dataTree.getEffectiveModelContext();
+            root = dataTree.modelContext();
         }
     }
 
index 1f22c80b2458a30a3a34209ede704bda45a266ef..4080d04844b9c16863572256d5d555ae3398dd80 100644 (file)
@@ -81,7 +81,7 @@ final class XpathStringParsingPathArgumentBuilder implements Mutable {
         offset = 0;
 
         final DataSchemaContextTree tree = codec.getDataContextTree();
-        stack = SchemaInferenceStack.of(tree.getEffectiveModelContext());
+        stack = SchemaInferenceStack.of(tree.modelContext());
         current = tree.getRoot();
     }
 
index adba8a8d63c04cfee860261199a1306248acda60..54bc7f89a6e1cd858e015cd819d7e67d298dc291 100644 (file)
@@ -39,7 +39,6 @@ import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition;
-import org.opendaylight.yangtools.yang.model.spi.AbstractEffectiveModelContextProvider;
 import org.opendaylight.yangtools.yang.model.util.LeafrefResolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -51,15 +50,15 @@ import org.slf4j.LoggerFactory;
  *
  * @param <T> Codec type
  */
-public abstract class AbstractCodecFactory<T extends TypeAwareCodec<?, ?, ?>>
-        extends AbstractEffectiveModelContextProvider {
+public abstract class AbstractCodecFactory<T extends TypeAwareCodec<?, ?, ?>> {
     private static final Logger LOG = LoggerFactory.getLogger(AbstractCodecFactory.class);
 
+    private final @NonNull EffectiveModelContext modelContext;
     private final @NonNull CodecCache<T> cache;
 
-    protected AbstractCodecFactory(final @NonNull EffectiveModelContext schemaContext,
+    protected AbstractCodecFactory(final @NonNull EffectiveModelContext modelContext,
             final @NonNull CodecCache<T> cache) {
-        super(schemaContext);
+        this.modelContext = requireNonNull(modelContext);
         this.cache = requireNonNull(cache);
     }
 
@@ -102,6 +101,15 @@ public abstract class AbstractCodecFactory<T extends TypeAwareCodec<?, ?, ?>>
         return cache.getComplex(schema, ret);
     }
 
+    /**
+     * Return the {@link EffectiveModelContext} backing this factory.
+     *
+     * @return the {@link EffectiveModelContext} backing this factory
+     */
+    public final @NonNull EffectiveModelContext modelContext() {
+        return modelContext;
+    }
+
     protected abstract T binaryCodec(BinaryTypeDefinition type);
 
     protected abstract T booleanCodec(BooleanTypeDefinition type);
index 6d76f23a7ed790d5d696d9a277cda717203da528..cba4c3c08f56cb409d1ec0e270925b0e842cfc23 100644 (file)
@@ -198,9 +198,8 @@ public abstract class AbstractInputStreamNormalizer<T extends TypeAwareCodec<?,
         @NonNull QName expected, @NonNull InputStream stream) throws IOException, NormalizationException;
 
     private void checkInference(final EffectiveStatementInference inference) {
-        final var modelContext = inference.getEffectiveModelContext();
-        final var local = getEffectiveModelContext();
-        if (!local.equals(modelContext)) {
+        final var local = modelContext();
+        if (!local.equals(inference.modelContext())) {
             throw new IllegalArgumentException("Mismatched inference, expecting model context " + local);
         }
     }
index e9b644e4e221675fbbe3f0b4d73f956033493e3c..bd111099083ec56afd6744f73586b18c1ddf491d 100644 (file)
@@ -37,7 +37,7 @@ class YT1412Test {
 
     private static DataSchemaContextTree CONTEXT;
 
-    private final SchemaInferenceStack stack = SchemaInferenceStack.of(CONTEXT.getEffectiveModelContext());
+    private final SchemaInferenceStack stack = SchemaInferenceStack.of(CONTEXT.modelContext());
 
     @BeforeAll
     static void init() {
diff --git a/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/EffectiveModelContextListener.java b/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/EffectiveModelContextListener.java
deleted file mode 100644 (file)
index bc308da..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.model.api;
-
-import com.google.common.annotations.Beta;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-
-/**
- * Interface for listeners interested in updates of an {@link EffectiveModelContext}.
- */
-@Beta
-@NonNullByDefault
-public interface EffectiveModelContextListener {
-    /**
-     * Invoked when the model context changes.
-     *
-     * @param newModelContext New model context being installed
-     */
-    void onModelContextUpdated(EffectiveModelContext newModelContext);
-}
diff --git a/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/EffectiveModelContextProvider.java b/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/EffectiveModelContextProvider.java
deleted file mode 100644 (file)
index 7b33b4a..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.model.api;
-
-import com.google.common.annotations.Beta;
-import org.eclipse.jdt.annotation.NonNull;
-
-/**
- * A static provider of an {@link EffectiveModelContext}.
- *
- * @author Robert Varga
- */
-@Beta
-public interface EffectiveModelContextProvider {
-    /**
-     * Return the {@link EffectiveModelContext} attached to this object.
-     *
-     * @return An EffectiveModelContext instance.
-     * @throws IllegalStateException if the context is not available.
-     */
-    @NonNull EffectiveModelContext getEffectiveModelContext();
-}
index 95e2e6416f196d33d61266bf0c47f314e7026e9e..15536f653028f8f205ff96b86abdff305ab9ac83 100644 (file)
@@ -19,7 +19,14 @@ import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
  * derived from the line of reasoning.
  */
 @Beta
-public interface EffectiveStatementInference extends EffectiveModelContextProvider, Immutable {
+public interface EffectiveStatementInference extends Immutable {
+    /**
+     * Return the {@link EffectiveModelContext} against which this inference is made.
+     *
+     * @return the {@link EffectiveModelContext} against which this inference is made
+     */
+    @NonNull EffectiveModelContext modelContext();
+
     /**
      * An {@code Unmodifiable} {@link List} of {@link EffectiveStatement}s, ordered in some meaningful way. Precise
      * semantics of the statement order is clarified by individual {@link EffectiveStatementInference} specializations.
diff --git a/model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/AbstractEffectiveModelContextProvider.java b/model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/AbstractEffectiveModelContextProvider.java
deleted file mode 100644 (file)
index cf9e744..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2020 PANTHEON.tech s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.model.spi;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
-
-/**
- * Utility superclass for classes returning a constant {@link EffectiveModelContext}.
- */
-@Beta
-@NonNullByDefault
-public abstract class AbstractEffectiveModelContextProvider implements EffectiveModelContextProvider {
-    private final EffectiveModelContext modelContext;
-
-    protected AbstractEffectiveModelContextProvider(final EffectiveModelContext modelContext) {
-        this.modelContext = requireNonNull(modelContext);
-    }
-
-    @Override
-    public final EffectiveModelContext getEffectiveModelContext() {
-        return modelContext;
-    }
-
-    @Override
-    public final String toString() {
-        return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
-    }
-
-    protected ToStringHelper addToStringAttributes(final ToStringHelper helper) {
-        return helper.add("modelContext", modelContext);
-    }
-}
index 4055e08ee10f94cc3a99a08461b20daa7b5ed6f0..4fab9040c41321c57a2936d5067e655cadd2a342 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.model.spi;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.collect.ImmutableList;
 import java.util.List;
@@ -19,20 +20,36 @@ import org.opendaylight.yangtools.yang.model.api.EffectiveStatementInference;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 
 /**
- * A simple capture of an {@link AbstractEffectiveModelContextProvider} and {@link EffectiveStatementInference}s.
+ * A {@link EffectiveStatementInference}s with its attached {@link EffectiveModelContext}.
  *
  * @param <T> constituent {@link EffectiveStatement} type
  */
 @Beta
 public abstract class AbstractEffectiveStatementInference<T extends EffectiveStatement<?, ?>>
-        extends AbstractEffectiveModelContextProvider implements EffectiveStatementInference {
+        implements EffectiveStatementInference {
+    private final @NonNull EffectiveModelContext modelContext;
+
     protected AbstractEffectiveStatementInference(final @NonNull EffectiveModelContext modelContext) {
-        super(modelContext);
+        this.modelContext = requireNonNull(modelContext);
+    }
+
+    @Override
+    public final EffectiveModelContext modelContext() {
+        return modelContext;
     }
 
     @Override
     public abstract List<T> statementPath();
 
+    @Override
+    public final String toString() {
+        return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
+    }
+
+    protected ToStringHelper addToStringAttributes(final ToStringHelper helper) {
+        return helper.add("modelContext", modelContext);
+    }
+
     /**
      * A simple capture of an {@link AbstractEffectiveStatementInference} and a list of {@link EffectiveStatement}s. No
      * further guarantees are made.
index 4e01e4551707916f33618ce09e0d0f7940998950..edbf8ac31aabd4f7768db537dca0fb65e4877cfb 100644 (file)
@@ -26,8 +26,8 @@ import org.opendaylight.yangtools.yang.model.spi.AbstractEffectiveStatementInfer
 import org.slf4j.LoggerFactory;
 
 /**
- * Default implementation of a {@link SchemaTreeInference}. Guaranteed to be consistent with its
- * {@link #getEffectiveModelContext()}.
+ * Default implementation of a {@link SchemaTreeInference}. Guaranteed to be consistent with its
+ * {@link #modelContext()}.
  */
 @Beta
 @NonNullByDefault
index 90b420510c7a217ca555795e535007b3aeef9d98..60c4789bdddeb661a029018dc820064fd05cd1e0 100644 (file)
@@ -37,7 +37,7 @@ class YT1414Test {
     void testUnsafeOf() {
         final var path = ImmutableList.of(container);
         final var inference = DefaultSchemaTreeInference.unsafeOf(modelContext, path);
-        assertSame(modelContext, inference.getEffectiveModelContext());
+        assertSame(modelContext, inference.modelContext());
         assertSame(path, inference.statementPath());
     }
 
@@ -53,7 +53,7 @@ class YT1414Test {
         final var path = ImmutableList.of(container);
         final var inference = DefaultSchemaTreeInference.verifiedOf(modelContext, path);
 
-        assertSame(modelContext, inference.getEffectiveModelContext());
+        assertSame(modelContext, inference.modelContext());
         assertSame(path, inference.statementPath());
     }
 
index 053fd411556dc0cdfdeb5d8daade37f09bf0af8e..f498fb0f8a7cbcc42bc6b3ba92dde8c88cc95004 100644 (file)
@@ -7,14 +7,20 @@
  */
 package org.opendaylight.yangtools.yang.model.util;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
 import com.google.common.collect.ImmutableBiMap;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamException;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.BiMapYangNamespaceContext;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.YangNamespaceContext;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.spi.AbstractEffectiveModelContextProvider;
 
 /**
  * Utility {@link YangNamespaceContext} backed by a SchemaContext, resolving namespaces to their module names. This
@@ -26,14 +32,14 @@ import org.opendaylight.yangtools.yang.model.spi.AbstractEffectiveModelContextPr
  * resolved by using the latest revision available.
  */
 @Beta
-public final class ModuleNameNamespaceContext extends AbstractEffectiveModelContextProvider
-        implements YangNamespaceContext {
+public final class ModuleNameNamespaceContext implements YangNamespaceContext {
     @java.io.Serial
-    private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 2L;
+
+    private final @NonNull EffectiveModelContext modelContext;
 
-    @SuppressFBWarnings(value = "SE_NO_SUITABLE_CONSTRUCTOR", justification = "Handled through writeReplace()")
-    public ModuleNameNamespaceContext(final EffectiveModelContext schemaContext) {
-        super(schemaContext);
+    public ModuleNameNamespaceContext(final EffectiveModelContext modelContext) {
+        this.modelContext = requireNonNull(modelContext);
     }
 
     /**
@@ -43,7 +49,7 @@ public final class ModuleNameNamespaceContext extends AbstractEffectiveModelCont
      */
     public BiMapYangNamespaceContext toBiMap() {
         final var builder = ImmutableBiMap.<String, QNameModule>builder();
-        for (var module : getEffectiveModelContext().getModuleStatements().values()) {
+        for (var module : modelContext.getModuleStatements().values()) {
             final var name = module.argument().getLocalName();
             builder.put(name, findNamespaceForPrefix(name).orElseThrow());
         }
@@ -52,13 +58,13 @@ public final class ModuleNameNamespaceContext extends AbstractEffectiveModelCont
 
     @Override
     public QNameModule namespaceForPrefix(final String prefix) {
-        final var modules = getEffectiveModelContext().findModuleStatements(prefix).iterator();
+        final var modules = modelContext.findModuleStatements(prefix).iterator();
         return modules.hasNext() ? modules.next().localQNameModule() : null;
     }
 
     @Override
     public String prefixForNamespace(final QNameModule namespace) {
-        return getEffectiveModelContext().findModuleStatement(namespace)
+        return modelContext.findModuleStatement(namespace)
             .map(module -> module.argument().getLocalName())
             .orElse(null);
     }
@@ -67,4 +73,23 @@ public final class ModuleNameNamespaceContext extends AbstractEffectiveModelCont
     private Object writeReplace() {
         return toBiMap();
     }
+
+    @java.io.Serial
+    private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
+        throwNSE();
+    }
+
+    @java.io.Serial
+    private void readObjectNoData() throws ObjectStreamException {
+        throwNSE();
+    }
+
+    @java.io.Serial
+    private void writeObject(final ObjectOutputStream stream) throws IOException {
+        throwNSE();
+    }
+
+    private static void throwNSE() throws NotSerializableException {
+        throw new NotSerializableException(ModuleNameNamespaceContext.class.getName());
+    }
 }
index 2a71b1e9a6d3ab6e2d55c1b974b1252544f2e900..aa514c49e120a8df111eb02c57b323988666eae8 100644 (file)
@@ -32,7 +32,6 @@ import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
 import org.opendaylight.yangtools.yang.common.YangDataName;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
 import org.opendaylight.yangtools.yang.model.api.EffectiveStatementInference;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.PathExpression;
@@ -74,7 +73,7 @@ import org.slf4j.LoggerFactory;
  * This class is designed for single-threaded uses and does not make any guarantees around concurrent access.
  */
 @Beta
-public final class SchemaInferenceStack implements Mutable, EffectiveModelContextProvider, LeafrefResolver {
+public final class SchemaInferenceStack implements Mutable, LeafrefResolver {
     /**
      * Semantic binding of {@link EffectiveStatementInference} produced by {@link SchemaInferenceStack}. Sequence of
      * {@link #statementPath()} is implementation-specific.
@@ -142,7 +141,7 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
          * @return A new stack
          */
         public @NonNull SchemaInferenceStack toSchemaInferenceStack() {
-            return new SchemaInferenceStack(getEffectiveModelContext(), deque, currentModule, groupingDepth, clean);
+            return new SchemaInferenceStack(modelContext(), deque, currentModule, groupingDepth, clean);
         }
     }
 
@@ -158,7 +157,7 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
         }
     }
 
-    private final @NonNull EffectiveModelContext effectiveModel;
+    private final @NonNull EffectiveModelContext modelContext;
     private final ArrayDeque<EffectiveStatement<?, ?>> deque;
 
     private @Nullable ModuleEffectiveStatement currentModule;
@@ -170,22 +169,22 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
 
     private SchemaInferenceStack(final EffectiveModelContext effectiveModel, final int expectedSize) {
         deque = new ArrayDeque<>(expectedSize);
-        this.effectiveModel = requireNonNull(effectiveModel);
+        modelContext = requireNonNull(effectiveModel);
         clean = true;
     }
 
     private SchemaInferenceStack(final SchemaInferenceStack source) {
         deque = source.deque.clone();
-        effectiveModel = source.effectiveModel;
+        modelContext = source.modelContext;
         currentModule = source.currentModule;
         groupingDepth = source.groupingDepth;
         clean = source.clean;
     }
 
-    private SchemaInferenceStack(final EffectiveModelContext effectiveModel,
+    private SchemaInferenceStack(final EffectiveModelContext modelContext,
             final ArrayDeque<EffectiveStatement<?, ?>> deque, final ModuleEffectiveStatement currentModule,
             final int groupingDepth, final boolean clean) {
-        this.effectiveModel = requireNonNull(effectiveModel);
+        this.modelContext = requireNonNull(modelContext);
         this.deque = deque.clone();
         this.currentModule = currentModule;
         this.groupingDepth = groupingDepth;
@@ -193,7 +192,7 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
     }
 
     private SchemaInferenceStack(final EffectiveModelContext effectiveModel) {
-        this.effectiveModel = requireNonNull(effectiveModel);
+        modelContext = requireNonNull(effectiveModel);
         deque = new ArrayDeque<>();
         clean = true;
     }
@@ -234,7 +233,7 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
      */
     public static @NonNull SchemaInferenceStack ofInference(final EffectiveStatementInference inference) {
         if (inference.statementPath().isEmpty()) {
-            return new SchemaInferenceStack(inference.getEffectiveModelContext());
+            return new SchemaInferenceStack(inference.modelContext());
         } else if (inference instanceof SchemaTreeInference sti) {
             return ofInference(sti);
         } else if (inference instanceof Inference inf) {
@@ -254,7 +253,7 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
      */
     public static @NonNull SchemaInferenceStack ofInference(final SchemaTreeInference inference) {
         return inference instanceof DefaultSchemaTreeInference dsti ? ofInference(dsti)
-            : of(inference.getEffectiveModelContext(), inference.toSchemaNodeIdentifier());
+            : of(inference.modelContext(), inference.toSchemaNodeIdentifier());
     }
 
     /**
@@ -277,7 +276,7 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
 
     private static @NonNull SchemaInferenceStack ofTrusted(final DefaultSchemaTreeInference inference) {
         final var path = inference.statementPath();
-        final var ret = new SchemaInferenceStack(inference.getEffectiveModelContext(), path.size());
+        final var ret = new SchemaInferenceStack(inference.modelContext(), path.size());
         ret.currentModule = ret.getModule(path.get(0).argument());
         ret.deque.addAll(path);
         return ret;
@@ -285,7 +284,7 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
 
     @VisibleForTesting
     static @NonNull SchemaInferenceStack ofUntrusted(final DefaultSchemaTreeInference inference) {
-        final var ret = of(inference.getEffectiveModelContext(), inference.toSchemaNodeIdentifier());
+        final var ret = of(inference.modelContext(), inference.toSchemaNodeIdentifier());
         if (!Iterables.elementsEqual(ret.deque, inference.statementPath())) {
             throw new IllegalArgumentException("Provided " + inference + " is not consistent with resolved path "
                 + ret.toSchemaTreeInference());
@@ -310,9 +309,13 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
         return ret;
     }
 
-    @Override
-    public EffectiveModelContext getEffectiveModelContext() {
-        return effectiveModel;
+    /**
+     * Return the {@link EffectiveModelContext} this stack operates on.
+     *
+     * @return the {@link EffectiveModelContext} this stack operates on
+     */
+    public @NonNull EffectiveModelContext modelContext() {
+        return modelContext;
     }
 
     /**
@@ -561,7 +564,7 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
 
         final var checkedName = requireNonNull(name);
         final var namespace = name.module();
-        final var module = effectiveModel.getModuleStatements().get(namespace);
+        final var module = modelContext.getModuleStatements().get(namespace);
         if (module == null) {
             throw new IllegalArgumentException("Module for " + namespace + " not found");
         }
@@ -759,7 +762,7 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
      * @return An {@link Inference}
      */
     public @NonNull Inference toInference() {
-        return new Inference(effectiveModel, deque.clone(), currentModule, groupingDepth, clean);
+        return new Inference(modelContext, deque.clone(), currentModule, groupingDepth, clean);
     }
 
     /**
@@ -770,7 +773,7 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
      */
     public @NonNull SchemaTreeInference toSchemaTreeInference() {
         checkInInstantiatedContext();
-        return DefaultSchemaTreeInference.unsafeOf(getEffectiveModelContext(), reconstructDeque().stream()
+        return DefaultSchemaTreeInference.unsafeOf(modelContext, reconstructDeque().stream()
             .map(stmt -> (SchemaTreeEffectiveStatement<?>) stmt)
             .collect(ImmutableList.toImmutableList()));
     }
@@ -905,7 +908,7 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
     }
 
     private @NonNull ModuleEffectiveStatement getModule(final @NonNull QName nodeIdentifier) {
-        final var module = effectiveModel.getModuleStatements().get(nodeIdentifier.getModule());
+        final var module = modelContext.getModuleStatements().get(nodeIdentifier.getModule());
         if (module == null) {
             throw new IllegalArgumentException("Module for " + nodeIdentifier + " not found");
         }
@@ -936,7 +939,7 @@ public final class SchemaInferenceStack implements Mutable, EffectiveModelContex
 
     private SchemaInferenceStack reconstructSchemaInferenceStack() {
         // Let's walk all statements and decipher them into a temporary stack
-        final var tmp = new SchemaInferenceStack(effectiveModel, deque.size());
+        final var tmp = new SchemaInferenceStack(modelContext, deque.size());
         for (var stmt : deque) {
             // Order of checks is significant
             if (stmt instanceof DataTreeEffectiveStatement<?> dataTree) {