Class Axon4ToAxon5QueryResponseTypes

java.lang.Object
org.openrewrite.Recipe
org.axonframework.migration.Axon4ToAxon5QueryResponseTypes
All Implemented Interfaces:
Cloneable

public class Axon4ToAxon5QueryResponseTypes extends org.openrewrite.Recipe
Unwraps Axon Framework 4 ResponseTypes wrappers on AF5-shape (typed-payload, two-argument) J.MethodInvocation calls against QueryGateway.

AF5 dropped the ResponseType SPI: the gateway now accepts a plain Class<R> for single-response queries and exposes a separate queryMany(...) for multi-response queries. For call sites that already pass an object payload — i.e. the AF5 shape queryGateway.query(payload, ResponseTypes.instanceOf(R.class)) — the wrapper can be removed mechanically:

  • query(payload, instanceOf(R.class))query(payload, R.class)
  • query(payload, optionalInstanceOf(R.class))query(payload, R.class) — the future resolves to null when absent in AF5; behaviour-preserving rewrite.
  • query(payload, multipleInstancesOf(R.class))queryMany(payload, R.class) — the only paired method-name change.

Deliberately conservative scope. The recipe never fires on the three-argument AF4 form query(String name, Object payload, ResponseType) — that form has no AF5 overload, and silently rewriting it would (a) produce code that does not compile and (b) destroy the fingerprint that the LLM-driven axon4-to-axon5-querygateway skill needs to recognise the AF4 string-named pattern (so it can introduce typed query message classes). For the same reason the recipe skips subscriptionQuery(...) entirely — even the typed-payload form needs a structural rewrite of the surrounding SubscriptionQueryResult.initialResult/updates/close ceremony, which the skill must drive. streamingQuery(...) already takes a plain Class<R> in AF4, so there is no wrapper to unwrap.

Imports for org.axonframework.messaging.responsetypes.ResponseType and …ResponseTypes (including static …ResponseTypes.*) are removed only after the file has no remaining references to those types — projects that mix the two-argument AF5 shape with still-untouched three-argument AF4 sites keep their imports until the per-construct skill finishes the migration.

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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    org.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

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Axon4ToAxon5QueryResponseTypes

      public Axon4ToAxon5QueryResponseTypes()
  • Method Details

    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in class org.openrewrite.Recipe
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in class org.openrewrite.Recipe
    • getVisitor

      public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor()
      Overrides:
      getVisitor in class org.openrewrite.Recipe