Package org.axonframework.migration
Class MigrateSequencingPolicyLambda
java.lang.Object
org.openrewrite.Recipe
org.axonframework.migration.MigrateSequencingPolicyLambda
- All Implemented Interfaces:
Cloneable
public class MigrateSequencingPolicyLambda
extends org.openrewrite.Recipe
Rewrites single-argument
SequencingPolicy lambdas to the AF5 two-argument shape with an
Optional return.
The SequencingPolicy functional interface changed in two ways between AF4 and AF5:
- The single method took
Object getSequenceIdentifierFor(T event)(one argument, nullableObjectreturn) and now takesOptional<Object> sequenceIdentifierFor(M message, ProcessingContext context)(two arguments,Optional<Object>return). - The
<T>type parameter was renamed to<M extends Message>.
e -> e.getMetaData().get(KEY); that does not satisfy
the AF5 functional interface (wrong arity, wrong return type), and the user must rewrite both the
parameter list and the return.
This recipe handles the common shape — a single-parameter lambda with an expression body whose target
type is SequencingPolicy — and rewrites it to (msg, ctx) -> Optional.ofNullable(body),
preserving the original parameter name and using Optional.ofNullable to retain the AF4 contract
that null indicates "no sequencing requirement". Lambdas with block bodies, multiple parameters,
or anonymous inner classes implementing SequencingPolicy are left alone for manual rewriting —
the structural variety is too broad for a safe automatic transformation.
- Since:
- 5.1.1
- Author:
- Mateusz Nowak
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openrewrite.Recipe
org.openrewrite.Recipe.Builder, org.openrewrite.Recipe.DelegatingRecipe -
Field Summary
Fields inherited from class org.openrewrite.Recipe
contributors, examples, PANIC -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.openrewrite.TreeVisitor<?, org.openrewrite.ExecutionContext> Methods inherited from class org.openrewrite.Recipe
addDataTable, builder, buildRecipeList, causesAnotherCycle, clone, createRecipeDescriptor, equals, getContributors, getDataTableDescriptors, getDescriptor, getEstimatedEffortPerOccurrence, getExamples, getInstanceName, getInstanceNameSuffix, getJacksonPolymorphicTypeTag, getMaintainers, getName, getRecipeList, getTags, hashCode, maxCycles, noop, onComplete, run, run, run, setContributors, setExamples, validate, validate, validateAll, validateAll, withOptions
-
Constructor Details
-
MigrateSequencingPolicyLambda
public MigrateSequencingPolicyLambda()
-
-
Method Details
-
getDisplayName
- Specified by:
getDisplayNamein classorg.openrewrite.Recipe
-
getDescription
- Specified by:
getDescriptionin classorg.openrewrite.Recipe
-
getVisitor
public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor()- Overrides:
getVisitorin classorg.openrewrite.Recipe
-