Class JsonMqttPayloadSerDes

java.lang.Object
io.micronaut.mqtt.serdes.JsonMqttPayloadSerDes
All Implemented Interfaces:
io.micronaut.core.order.Ordered, MqttPayloadSerDes<Object>

@Singleton public class JsonMqttPayloadSerDes extends Object implements MqttPayloadSerDes<Object>
Serializes and deserializes objects as JSON using Jackson.
Since:
1.1.0
Author:
James Kleeh
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Integer
    The order of this serDes.

    Fields inherited from interface io.micronaut.core.order.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    JsonMqttPayloadSerDes(io.micronaut.json.JsonMapper jsonMapper)
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    deserialize(byte[] payload, io.micronaut.core.type.Argument<Object> type)
    Deserializes the message into the requested type.
    int
     
    byte[]
    Serializes the data into a byte[] to be published to MQTT.
    boolean
    supports(io.micronaut.core.type.Argument<Object> argument)
    Determines if this serdes supports the given type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ORDER

      public static final Integer ORDER
      The order of this serDes.
  • Constructor Details

    • JsonMqttPayloadSerDes

      public JsonMqttPayloadSerDes(io.micronaut.json.JsonMapper jsonMapper)
      Default constructor.
      Parameters:
      jsonMapper - The json mapper
      Since:
      2.1.0
  • Method Details

    • deserialize

      public Object deserialize(byte[] payload, io.micronaut.core.type.Argument<Object> type)
      Description copied from interface: MqttPayloadSerDes
      Deserializes the message into the requested type.
      Specified by:
      deserialize in interface MqttPayloadSerDes<Object>
      Parameters:
      payload - The message to deserialize
      type - The type to be returned
      Returns:
      The deserialized body
    • serialize

      public byte[] serialize(Object data)
      Description copied from interface: MqttPayloadSerDes
      Serializes the data into a byte[] to be published to MQTT.
      Specified by:
      serialize in interface MqttPayloadSerDes<Object>
      Parameters:
      data - The data to serialize
      Returns:
      The message body
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface io.micronaut.core.order.Ordered
    • supports

      public boolean supports(io.micronaut.core.type.Argument<Object> argument)
      Description copied from interface: MqttPayloadSerDes
      Determines if this serdes supports the given type.
      Specified by:
      supports in interface MqttPayloadSerDes<Object>
      Parameters:
      argument - The type
      Returns:
      True if the type is supported