Class ResponseTypes

java.lang.Object
org.axonframework.messaging.responsetypes.ResponseTypes

public abstract class ResponseTypes extends Object
Utility class containing static methods to obtain instances of ResponseType.
Since:
3.2
Author:
Steven van Beelen
  • Method Details

    • instanceOf

      public static <R> ResponseType<R> instanceOf(Class<R> type)
      Specify the desire to retrieve a single instance of type R when performing a query.
      Type Parameters:
      R - the generic type of the instantiated ResponseType
      Parameters:
      type - the R which is expected to be the response type
      Returns:
      a ResponseType specifying the desire to retrieve a single instance of type R
    • optionalInstanceOf

      public static <R> ResponseType<Optional<R>> optionalInstanceOf(Class<R> type)
      Specify the desire to retrieve an Optional<R> when performing a query.

      Note that this ResponseType will declare the same expectations on the Query Result as the ResponseType returned by instanceOf(Class). The difference is that the result provided by this ResponseType is wrapped in an Optional.

      Type Parameters:
      R - the generic type of the instantiated ResponseType
      Parameters:
      type - the R which is expected to be the response type
      Returns:
      a ResponseType specifying the desire to retrieve an optional instance of type R
    • multipleInstancesOf

      public static <R> ResponseType<List<R>> multipleInstancesOf(Class<R> type)
      Specify the desire to retrieve a collection of instances of type R when performing a query. If no handler is found that can retrieve the type as a collection, a handler is selected that returns a single instance of the provided type.
      Type Parameters:
      R - the generic type of the instantiated ResponseType
      Parameters:
      type - the R which is expected to be the response type
      Returns:
      a ResponseType specifying the desire to retrieve a collection of instances of type R
    • publisherOf

      public static <R> ResponseType<org.reactivestreams.Publisher<R>> publisherOf(Class<R> type)
      Specify the desire to retrieve a Publisher (reactive stream) of instances of type R when performing a query.
      Type Parameters:
      R - the generic type of the instantiated ResponseType
      Parameters:
      type - the R which is expected to be the response type
      Returns:
      a ResponseType specifying the desire to retrieve a publisher of instances of type R