Interface MessageConverter

All Superinterfaces:
Converter, DescribableComponent
All Known Implementing Classes:
DelegatingMessageConverter

public interface MessageConverter extends Converter
A converter specific for Messages, acting on the payload.

This interface serves the purpose of enforcing use of the right type of converter. Implementation of this interface typically delegate operations to a Converter instance.

Since:
5.0.0
Author:
Steven van Beelen
  • Method Details

    • convertPayload

      @Nullable default <M extends Message, T> T convertPayload(@Nonnull M message, @Nonnull Class<T> targetType)
      Converts the given message's payload into a payload of the given targetType.
      Type Parameters:
      M - The type of Message to convert the payload for.
      T - The target data type.
      Parameters:
      message - The Message to convert the payload for.
      targetType - The type to convert the payload into.
      Returns:
      A converted version of the given Message's payload into the given targetType.
    • convertPayload

      @Nullable <M extends Message, T> T convertPayload(@Nonnull M message, @Nonnull Type targetType)
      Converts the given message's payload into a payload of the given targetType.
      Type Parameters:
      M - The type of Message to convert the payload for.
      T - The target data type.
      Parameters:
      message - The Message to convert the payload for.
      targetType - The type to convert the payload into.
      Returns:
      A converted version of the given Message's payload into the given targetType.
    • convertMessage

      @Nonnull default <M extends Message, T> M convertMessage(@Nonnull M message, @Nonnull Class<T> targetType)
      Converts the given message's payload to the given targetType, returning a new Message with the converted payload.
      Type Parameters:
      M - The type of Message to convert and return.
      T - The target data type.
      Parameters:
      message - The Message to convert the payload for.
      targetType - The type to convert the payload into.
      Returns:
      A new Message containing the converted version of the given message's payload into the given targetType.
    • convertMessage

      @Nonnull <M extends Message> M convertMessage(@Nonnull M message, @Nonnull Type targetType)
      Converts the given message's payload to the given targetType, returning a new Message with the converted payload.
      Type Parameters:
      M - The type of Message to convert and return.
      Parameters:
      message - The Message to convert the payload for.
      targetType - The type to convert the payload into.
      Returns:
      A new Message containing the converted version of the given message's payload into the given targetType.