Bump yangtools to 13.0.0
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / GeneratorContext.java
index fb17e65bfe22edff54dafd9d08e973d45f7a03fe..92ca3341c03cc44abe9a61e0f5b7165b5df125cf 100644 (file)
@@ -7,10 +7,13 @@
  */
 package org.opendaylight.mdsal.binding.generator.impl.reactor;
 
-import edu.umd.cs.findbugs.annotations.Nullable;
+import static java.util.Objects.requireNonNull;
+
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.PathExpression;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 
@@ -18,6 +21,16 @@ import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
  * Abstract view on generation tree as viewed by a particular {@link Generator}.
  */
 abstract class GeneratorContext {
+    private final @NonNull EffectiveModelContext modelContext;
+
+    GeneratorContext(final EffectiveModelContext modelContext) {
+        this.modelContext = requireNonNull(modelContext);
+    }
+
+    final @NonNull EffectiveModelContext modelContext() {
+        return modelContext;
+    }
+
     /**
      * Resolve generator for the type object pointed to by a {@code path} expression, or {@code null} it the if cannot
      * the current generator is nested inside a {@code grouping} and the generator cannot be found.
@@ -27,7 +40,7 @@ abstract class GeneratorContext {
      * @throws NullPointerException if {@code path} is {@code null}
      * @throws IllegalStateException if this generator is not inside a {@code grouping} and the path cannot be resolved
      */
-    abstract @Nullable AbstractTypeObjectGenerator<?> resolveLeafref(@NonNull PathExpression path);
+    abstract @Nullable AbstractTypeObjectGenerator<?, ?> resolveLeafref(@NonNull PathExpression path);
 
     /**
      * Resolve a tree-scoped namespace reference. This covers {@code typedef} and {@code grouping} statements, as per
@@ -40,15 +53,14 @@ abstract class GeneratorContext {
      * @throws NullPointerException if any argument is null
      * @throws IllegalStateException if the generator cannot be found
      */
-    abstract <E extends EffectiveStatement<QName, ?>, G extends AbstractExplicitGenerator<E>>
+    abstract <E extends EffectiveStatement<QName, ?>, G extends AbstractExplicitGenerator<E, ?>>
         @NonNull G resolveTreeScoped(@NonNull Class<G> type, @NonNull QName argument);
 
     abstract @NonNull ModuleGenerator resolveModule(@NonNull QNameModule namespace);
 
     final @NonNull IdentityGenerator resolveIdentity(final @NonNull QName name) {
         for (Generator gen : resolveModule(name.getModule())) {
-            if (gen instanceof IdentityGenerator) {
-                final IdentityGenerator idgen = (IdentityGenerator) gen;
+            if (gen instanceof final IdentityGenerator idgen) {
                 if (name.equals(idgen.statement().argument())) {
                     return idgen;
                 }