public interface MessageCodec<T>
Both operations throw IllegalArgumentException
, if conversion fails.
Modifier and Type | Method and Description |
---|---|
T |
decodeMessage(ByteBuffer message)
Decodes the specified message from binary.
|
ByteBuffer |
encodeMessage(T message)
Encodes the specified message into binary.
|
@Nullable ByteBuffer encodeMessage(@Nullable T message)
message
- the T message, possibly null.@Nullable T decodeMessage(@Nullable ByteBuffer message)
Warning: The ByteBuffer is "direct" and it won't be valid beyond this call. Storing
the ByteBuffer and using it later and will lead to a java.nio.BufferUnderflowException
.
If you want to retain the data you'll need to copy it.
message
- the ByteBuffer
message, possibly null.