SmartMessageConverter

An extended {@link MessageConverter} SPI with conversion hint support.

<p>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 {@code fromMessage} / {@code toMessage} variants.

@author Juergen Hoeller @since 4.2.1

Members

Aliases

fromMessage
alias fromMessage = MessageConverter.fromMessage
Undocumented in source.
toMessage
alias toMessage = MessageConverter.toMessage
Undocumented in source.

Functions

fromMessage
Object fromMessage(MessageBase message, TypeInfo targetClass, TypeInfo conversionHint)

A variant of {@link #fromMessage(Message, Class)} which takes an extra conversion context as an argument, allowing to take e.g. annotations on a payload parameter into account. @param message the input message @param targetClass the target class for the conversion @param conversionHint an extra object passed to the {@link MessageConverter}, e.g. the associated {@code MethodParameter} (may be {@code null}} @return the result of the conversion, or {@code null} if the converter cannot perform the conversion @see #fromMessage(Message, Class)

toMessage
MessageBase toMessage(Object payload, MessageHeaders headers, TypeInfo conversionHint)

A variant of {@link #toMessage(Object, MessageHeaders)} which takes an extra conversion context as an argument, allowing to take e.g. annotations on a return type into account. @param payload the Object to convert @param headers optional headers for the message (may be {@code null}) @param conversionHint an extra object passed to the {@link MessageConverter}, e.g. the associated {@code MethodParameter} (may be {@code null}} @return the new message, or {@code null} if the converter does not support the Object type or the target media type @see #toMessage(Object, MessageHeaders)

Inherited Members

From MessageConverter

fromMessage
Object fromMessage(MessageBase message, TypeInfo targetClass)

Convert the payload of a {@link Message} from a serialized form to a typed Object of the specified target class. The {@link MessageHeaders#CONTENT_TYPE} header should indicate the MIME type to convert from. <p>If the converter does not support the specified media type or cannot perform the conversion, it should return {@code null}. @param message the input message @param targetClass the target class for the conversion @return the result of the conversion, or {@code null} if the converter cannot perform the conversion

toMessage
MessageBase toMessage(Object payload, MessageHeaders headers)

Create a {@link Message} whose payload is the result of converting the given payload Object to serialized form. The optional {@link MessageHeaders} parameter may contain a {@link MessageHeaders#CONTENT_TYPE} header to specify the target media type for the conversion and it may contain additional headers to be added to the message. <p>If the converter does not support the specified media type or cannot perform the conversion, it should return {@code null}. @param payload the Object to convert @param headers optional headers for the message (may be {@code null}) @return the new message, or {@code null} if the converter does not support the Object type or the target media type

Meta