Interface Converter

All Superinterfaces:
DescribableComponent
All Known Subinterfaces:
EventConverter, MessageConverter
All Known Implementing Classes:
AvroConverter, ChainingContentTypeConverter, DelegatingEventConverter, DelegatingMessageConverter, JacksonConverter, PassThroughConverter

public interface Converter extends DescribableComponent
Interface describing a mechanism that can convert data from one to another type.

Used when object are added/retrieved from a storage solution or put on/received from a network. Clear example of this is the

invalid reference
org.axonframework.messaging.Message
.
Since:
3.0.0
Author:
Allard Buijze, Rene de Waele
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    canConvert(Class<?> sourceType, Class<?> targetType)
    Indicates whether this Converter is capable of converting the given sourceType to the targetType.
    boolean
    canConvert(Type sourceType, Type targetType)
    Indicates whether this Converter is capable of converting the given sourceType to the targetType.
    default <T> T
    convert(Object input, Class<T> targetType)
    Converts the given input object into an object of the given targetType.
    <T> T
    convert(Object input, Type targetType)
    Converts the given input object into an object of the given targetType.

    Methods inherited from interface org.axonframework.common.infra.DescribableComponent

    describeTo
  • Method Details

    • canConvert

      default boolean canConvert(@Nonnull Class<?> sourceType, @Nonnull Class<?> targetType)
      Indicates whether this Converter is capable of converting the given sourceType to the targetType.
      Parameters:
      sourceType - The type of data to convert from.
      targetType - The type of data to convert to.
      Returns:
      true if conversion is possible, false otherwise.
    • canConvert

      boolean canConvert(@Nonnull Type sourceType, @Nonnull Type targetType)
      Indicates whether this Converter is capable of converting the given sourceType to the targetType.
      Parameters:
      sourceType - The type of data to convert from.
      targetType - The type of data to convert to.
      Returns:
      true if conversion is possible, false otherwise.
    • convert

      @Nullable default <T> T convert(@Nullable Object input, @Nonnull Class<T> targetType)
      Converts the given input object into an object of the given targetType.
      Type Parameters:
      T - The target data type.
      Parameters:
      input - The value to convert.
      targetType - The type to convert the given input into.
      Returns:
      A converted version of the given input into the given targetType.
    • convert

      @Nullable <T> T convert(@Nullable Object input, @Nonnull Type targetType)
      Converts the given input object into an object of the given targetType.
      Type Parameters:
      T - The target data type.
      Parameters:
      input - The value to convert.
      targetType - The type to convert the given input into.
      Returns:
      A converted version of the given input into the given targetType.