Remove AbstractPathPrerequisite.modPhase 42/104842/4
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 13 Mar 2023 14:47:01 +0000 (15:47 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 13 Mar 2023 15:48:01 +0000 (16:48 +0100)
AbstractPathPrerequisite always operates on EFFECTIVE_MODEL, inline
the constant, simplifying interactions a bit.

Change-Id: I916fef0f476969620a7cfc7010de30e9633eb72b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ModifierImpl.java

index 918a737ab7b6e6069f65fce4cb6cdf28079ec08e..8ae904c200107044c8ddcc7b87a9a835a53cb973 100644 (file)
@@ -320,14 +320,11 @@ final class ModifierImpl implements ModelActionBuilder {
 
     private abstract static class AbstractPathPrerequisite<C extends StmtContext<?, ?, ?>, K>
             extends AbstractPrerequisite<C> implements OnNamespaceItemAdded {
-        private final ModelProcessingPhase modPhase;
         private final Iterable<K> keys;
         private final Iterator<K> it;
 
-        AbstractPathPrerequisite(final ModifierImpl modifier, final ModelProcessingPhase phase,
-                final Iterable<K> keys) {
+        AbstractPathPrerequisite(final ModifierImpl modifier, final Iterable<K> keys) {
             super(modifier);
-            this.modPhase = requireNonNull(phase);
             this.keys = requireNonNull(keys);
             it = keys.iterator();
         }
@@ -345,7 +342,7 @@ final class ModifierImpl implements ModelActionBuilder {
                 return;
             }
 
-            nextStep(modPhase, context, target);
+            nextStep(context, target);
 
             if (!it.hasNext()) {
                 // Last step: we are done
@@ -359,12 +356,11 @@ final class ModifierImpl implements ModelActionBuilder {
             hookOnto(target, namespace, it.next());
         }
 
-        abstract void nextStep(ModelProcessingPhase phase, StatementContextBase<?, ?, ?> current,
-            StatementContextBase<?, ?, ?> next);
+        abstract void nextStep(StatementContextBase<?, ?, ?> current, StatementContextBase<?, ?, ?> next);
 
         @Override
         final ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-            return super.addToStringAttributes(toStringHelper).add("phase", modPhase).add("keys", keys);
+            return super.addToStringAttributes(toStringHelper).add("phase", EFFECTIVE_MODEL).add("keys", keys);
         }
 
         final void hookOnto(final StmtContext<?, ?, ?> context, final ParserNamespace<?, ?> namespace) {
@@ -447,12 +443,11 @@ final class ModifierImpl implements ModelActionBuilder {
     private static final class PhaseRequirementInNamespacePath<C extends StmtContext<?, ?, ?>, K>
             extends AbstractPathPrerequisite<C, K> {
         PhaseRequirementInNamespacePath(final ModifierImpl modifier, final Iterable<K> keys) {
-            super(modifier, EFFECTIVE_MODEL, keys);
+            super(modifier, keys);
         }
 
         @Override
-        void nextStep(final ModelProcessingPhase phase, final StatementContextBase<?, ?, ?> current,
-                final StatementContextBase<?, ?, ?> next) {
+        void nextStep(final StatementContextBase<?, ?, ?> current, final StatementContextBase<?, ?, ?> next) {
             // No-op
         }
     }
@@ -490,7 +485,7 @@ final class ModifierImpl implements ModelActionBuilder {
     private static final class PhaseModificationInNamespacePath<C extends Mutable<?, ?, ?>, K>
             extends AbstractPathPrerequisite<C, K> implements ContextMutation {
         PhaseModificationInNamespacePath(final ModifierImpl modifier, final Iterable<K> keys) {
-            super(modifier, EFFECTIVE_MODEL, keys);
+            super(modifier, keys);
         }
 
         @Override
@@ -499,13 +494,12 @@ final class ModifierImpl implements ModelActionBuilder {
         }
 
         @Override
-        void nextStep(final ModelProcessingPhase phase, final StatementContextBase<?, ?, ?> current,
-                final StatementContextBase<?, ?, ?> next) {
+        void nextStep(final StatementContextBase<?, ?, ?> current, final StatementContextBase<?, ?, ?> next) {
             // Hook onto target: we either have a modification of the target itself or one of its children.
-            next.addMutation(phase, this);
+            next.addMutation(EFFECTIVE_MODEL, this);
             // We have completed the context -> target step, hence we are no longer directly blocking context from
             // making forward progress.
-            current.removeMutation(phase, this);
+            current.removeMutation(EFFECTIVE_MODEL, this);
         }
     }
 }