Interface EventConverter

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

public interface EventConverter extends Converter
A converter specific for EventMessages, 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 MessageConverter instance, unless the serialized format of events and other messages differ.

Since:
5.0.0
Author:
Steven van Beelen
  • Method Details

    • convertPayload

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

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

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

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