Class InstanceResponseType<R>

java.lang.Object
org.axonframework.messaging.responsetypes.AbstractResponseType<R>
org.axonframework.messaging.responsetypes.InstanceResponseType<R>
Type Parameters:
R - The response type which will be matched against and converted to
All Implemented Interfaces:
Serializable, ResponseType<R>

public class InstanceResponseType<R> extends AbstractResponseType<R>
A ResponseType implementation that will match with query handlers which return a single instance of the expected response type. If matching succeeds, the ResponseType.convert(Object) function will be called, which will cast the query handler it's response to R.
Since:
3.2
Author:
Steven van Beelen
See Also:
  • Constructor Details

    • InstanceResponseType

      @ConstructorProperties("expectedResponseType") public InstanceResponseType(Class<R> expectedResponseType)
      Instantiate a InstanceResponseType with the given expectedResponseType as the type to be matched against and to which the query response should be converted to.
      Parameters:
      expectedResponseType - the response type which is expected to be matched against and returned
  • Method Details

    • matches

      public boolean matches(Type responseType)
      Match the query handler its response Type with this implementation its responseType R. Will return true if the expected type is assignable to the response type, taking generic types into account.
      Parameters:
      responseType - the response Type of the query handler which is matched against
      Returns:
      true if the response type is assignable to the expected type, taking generic types into account
    • convert

      public R convert(Object response)
      Description copied from interface: ResponseType
      Converts the given response of type Object into the type R of this ResponseType instance. Should only be called if ResponseType.matches(Type) returns true. It is unspecified what this function does if the ResponseType.matches(Type) returned false.
      Parameters:
      response - the Object to convert into R
      Returns:
      a response of type R
    • responseMessagePayloadType

      public Class<R> responseMessagePayloadType()
      Description copied from interface: ResponseType
      Returns a Class representing the type of the payload to be contained in the response message.
      Returns:
      a Class representing the type of the payload to be contained in the response message
    • toString

      public String toString()
      Overrides:
      toString in class Object