public interface MessageConverter
Message
from serialized form to a typed
Object and vice versa. The MessageHeaders.CONTENT_TYPE
message header may be
used to specify the media type of the message content.Modifier and Type | Method and Description |
---|---|
java.lang.Object |
fromMessage(Message<?> message,
java.lang.Class<?> targetClass)
Convert the payload of a
Message from a serialized form to a typed Object
of the specified target class. |
Message<?> |
toMessage(java.lang.Object payload,
MessageHeaders headers)
Create a
Message whose payload is the result of converting the given
payload Object to serialized form. |
@Nullable java.lang.Object fromMessage(Message<?> message, java.lang.Class<?> targetClass)
Message
from a serialized form to a typed Object
of the specified target class. The MessageHeaders.CONTENT_TYPE
header
should indicate the MIME type to convert from.
If the converter does not support the specified media type or cannot perform
the conversion, it should return null
.
message
- the input messagetargetClass
- the target class for the conversionnull
if the converter cannot
perform the conversion@Nullable Message<?> toMessage(java.lang.Object payload, @Nullable MessageHeaders headers)
Message
whose payload is the result of converting the given
payload Object to serialized form. The optional MessageHeaders
parameter
may contain a 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.
If the converter does not support the specified media type or cannot perform
the conversion, it should return null
.
payload
- the Object to convertheaders
- optional headers for the message (may be null
)null
if the converter does not support the
Object type or the target media type