@Singleton public class JsonMqttPayloadSerDes extends java.lang.Object implements MqttPayloadSerDes<java.lang.Object>
Modifier and Type | Field and Description |
---|---|
static java.lang.Integer |
ORDER
The order of this serDes.
|
Constructor and Description |
---|
JsonMqttPayloadSerDes(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
deserialize(byte[] payload,
io.micronaut.core.type.Argument<java.lang.Object> type)
Deserializes the message into the requested type.
|
int |
getOrder() |
byte[] |
serialize(java.lang.Object data)
Serializes the data into a byte[] to be published
to MQTT.
|
boolean |
supports(io.micronaut.core.type.Argument<java.lang.Object> argument)
Determines if this serdes supports the given type.
|
public JsonMqttPayloadSerDes(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
objectMapper
- The jackson object mapperpublic java.lang.Object deserialize(byte[] payload, io.micronaut.core.type.Argument<java.lang.Object> type)
MqttPayloadSerDes
deserialize
in interface MqttPayloadSerDes<java.lang.Object>
payload
- The message to deserializetype
- The type to be returnedpublic byte[] serialize(java.lang.Object data)
MqttPayloadSerDes
serialize
in interface MqttPayloadSerDes<java.lang.Object>
data
- The data to serializepublic int getOrder()
getOrder
in interface io.micronaut.core.order.Ordered
public boolean supports(io.micronaut.core.type.Argument<java.lang.Object> argument)
MqttPayloadSerDes
supports
in interface MqttPayloadSerDes<java.lang.Object>
argument
- The type