Interface SmartMessageConverter

All Superinterfaces:
MessageConverter
All Known Implementing Classes:
AbstractJsonMessageConverter, AbstractMessageConverter, ByteArrayMessageConverter, CompositeMessageConverter, GsonMessageConverter, JsonbMessageConverter, KotlinSerializationJsonMessageConverter, MappingJackson2MessageConverter, MarshallingMessageConverter, ProtobufJsonFormatMessageConverter, ProtobufMessageConverter, StringMessageConverter

public interface SmartMessageConverter extends MessageConverter
An extended MessageConverter SPI with conversion hint support.

In case of a conversion hint being provided, the framework will call these extended methods if a converter implements this interface, instead of calling the regular fromMessage / toMessage variants.

Since:
4.2.1
Author:
Juergen Hoeller
  • Method Details

    • fromMessage

      @Nullable Object fromMessage(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint)
      A variant of MessageConverter.fromMessage(Message, Class) which takes an extra conversion context as an argument, allowing to take, for example, annotations on a payload parameter into account.
      Parameters:
      message - the input message
      targetClass - the target class for the conversion
      conversionHint - an extra object passed to the MessageConverter, for example, the associated MethodParameter (may be null)
      Returns:
      the result of the conversion, or null if the converter cannot perform the conversion
      See Also:
    • toMessage

      @Nullable Message<?> toMessage(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint)
      A variant of MessageConverter.toMessage(Object, MessageHeaders) which takes an extra conversion context as an argument, allowing to take, for example, annotations on a return type into account.
      Parameters:
      payload - the Object to convert
      headers - optional headers for the message (may be null)
      conversionHint - an extra object passed to the MessageConverter, for example, the associated MethodParameter (may be null)
      Returns:
      the new message, or null if the converter does not support the Object type or the target media type
      See Also: