Class DelegatingGeneralConverter

java.lang.Object
org.axonframework.conversion.DelegatingGeneralConverter
All Implemented Interfaces:
DescribableComponent, Converter, GeneralConverter

public class DelegatingGeneralConverter extends Object implements GeneralConverter
A GeneralConverter implementation delegating conversion operations to a Converter.

Useful to adapt any Converter to the GeneralConverter contract, ensuring callers work against the more specific GeneralConverter interface without restricting the types that can be converted.

Since:
5.1.0
Author:
Jakob Hatzl
  • Constructor Details

    • DelegatingGeneralConverter

      public DelegatingGeneralConverter(Converter delegate)
      Constructs a DelegatingGeneralConverter, delegating operations to the given delegate.
      Parameters:
      delegate - The converter to delegate all conversion operations to.
  • Method Details

    • convert

      public <T> @Nullable T convert(@Nullable Object input, Type targetType)
      Description copied from interface: Converter
      Converts the given input object into an object of the given targetType.
      Specified by:
      convert in interface Converter
      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.
    • describeTo

      public void describeTo(ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.

      Best Practices: As a general rule, all relevant fields of a DescribableComponent implementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing the describeTo method, who should focus on providing information that is useful for understanding the component's configuration and state.

      Example implementation:

       public void describeTo(ComponentDescriptor descriptor) {
           descriptor.describeProperty("name", this.name);
           descriptor.describeProperty("enabled", this.enabled);
           descriptor.describeProperty("configuration", this.configuration); // A nested component
           descriptor.describeProperty("handlers", this.eventHandlers);      // A collection
       }
       
      Specified by:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.
    • delegate

      @Internal public Converter delegate()
      Returns the delegate Converter this DelegatingGeneralConverter delegates to.

      Useful to construct other instances with the exact same Converter.

      Returns:
      The Converter this DelegatingGeneralConverter delegates to.