* Invoked once all prerequisites were met and forward references were resolved and inference action should be
* applied. Implementors may perform necessary changes to mutable objects which were declared.
*
- * @throws InferenceException If inference action can not be processed.
- * Note that this exception be used for user to debug YANG sources,
- * so should provide helpful context to fix issue in sources.
+ * @throws InferenceException If inference action can not be processed. Note that this exception be used for
+ * user to debug YANG sources, so should provide helpful context to fix issue in sources.
*/
- void apply(InferenceContext ctx) throws InferenceException;
+ void apply(InferenceContext ctx);
/**
* Invoked once one of prerequisites was not met, even after all other satisfiable inference actions were
* by user to debug YANG sources, hence it should provide helpful context to fix
* the issue in sources.
*/
- void prerequisiteFailed(Collection<? extends Prerequisite<?>> failed) throws InferenceException;
+ void prerequisiteFailed(Collection<? extends Prerequisite<?>> failed);
}
/**
Prerequisite<D> requiresDeclared(StmtContext<?, ?, ?> context, Class<N> namespace, K key);
/**
- * Action requires that the specified context completes specified phase.
+ * Action requires that the specified context completes specified phase before {@link #apply(InferenceAction)}
+ * may be invoked.
*
* @param context Statement context which needs to complete the transition.
* @param phase ModelProcessingPhase which must have completed
StmtContext<?, ?, ?> context, Class<N> namespace, NamespaceKeyCriterion<K> criterion,
ModelProcessingPhase phase);
- default @Nonnull <T extends Mutable<?, ?, ?>> Prerequisite<T> mutatesEffectiveCtx(final T stmt) {
- return mutatesCtx(stmt, EFFECTIVE_MODEL);
+ /**
+ * Action mutates the effective model of specified statement. This is a shorthand for
+ * {@code mutatesCtx(context, EFFECTIVE_MODEL}.
+ *
+ * @param context Target statement context
+ * @return A {@link Prerequisite} returning the requested context.
+ */
+ default @Nonnull <T extends Mutable<?, ?, ?>> Prerequisite<T> mutatesEffectiveCtx(final T context) {
+ return mutatesCtx(context, EFFECTIVE_MODEL);
}
@Nonnull <K, E extends EffectiveStatement<?, ?>, N extends IdentifierNamespace<K, ? extends StmtContext<?, ?, ?>>>
Prerequisite<Mutable<?, ?, E>> mutatesEffectiveCtx(StmtContext<?, ?, ?> context, Class<N> namespace, K key);
- @Nonnull <C extends StmtContext.Mutable<?, ?, ?>, CT extends C> Prerequisite<C> mutatesCtx(CT root,
+ default @Nonnull <K, E extends EffectiveStatement<?, ?>,
+ N extends IdentifierNamespace<K, ? extends StmtContext<?, ?, ?>>> Prerequisite<Mutable<?, ?, E>>
+ mutatesEffectiveCtxPath(final StmtContext<?, ?, ?> context, final Class<N> namespace,
+ final Iterable<K> keys) {
+ throw new UnsupportedOperationException(getClass() + " does not implement mutatesEffectiveCtxPath()");
+ }
+
+ /**
+ * Action mutates the specified statement in the specified phase. Target statement cannot complete specified
+ * phase before this action is applier.
+ *
+ * @param context Target statement context
+ * @return A {@link Prerequisite} returning the requested context.
+ */
+ @Nonnull <C extends Mutable<?, ?, ?>, T extends C> Prerequisite<C> mutatesCtx(T context,
ModelProcessingPhase phase);
- void apply(InferenceAction action) throws InferenceException;
+ /**
+ * Apply an {@link InferenceAction} when this action's prerequisites are resolved.
+ *
+ * @param action Inference action to apply
+ * @throws InferenceException if the action fails
+ * @throws NullPointerException if {@code action is null}
+ * @throws IllegalStateException if this action has an inference action already associated.
+ */
+ void apply(InferenceAction action);
/**
* Create a requirement on specified statement context to be declared.