Class JavaLangMqttPayloadSerDes

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

@Singleton public class JavaLangMqttPayloadSerDes extends Object implements MqttPayloadSerDes<Object>
Serializes and deserializes standard Java types.
Since:
1.1.0
Author:
James Kleeh
  • Field Details

  • Constructor Details

    • JavaLangMqttPayloadSerDes

      public JavaLangMqttPayloadSerDes()
      Default constructor.
  • Method Details

    • serialize

      public byte[] serialize(@Nullable @Nullable 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
    • deserialize

      public Object deserialize(byte[] payload, io.micronaut.core.type.Argument<Object> argument)
      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
      argument - The type to be returned
      Returns:
      The deserialized body
    • 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
    • getOrder

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

      @Nullable protected @Nullable MqttPayloadSerDes findSerDes(io.micronaut.core.type.Argument<?> type)
      Finds the correct serDes based on the type.
      Parameters:
      type - The java type
      Returns:
      The serdes, or null if none can be found
    • getStringSerDes

      @NonNull protected @NonNull MqttPayloadSerDes<String> getStringSerDes()
      Returns:
      The serDes that handles String
    • getShortSerDes

      @NonNull protected @NonNull MqttPayloadSerDes<Short> getShortSerDes()
      Returns:
      The serDes that handles Short
    • getIntegerSerDes

      @NonNull protected @NonNull MqttPayloadSerDes<Integer> getIntegerSerDes()
      Returns:
      The serDes that handles Integer
    • getLongSerDes

      @NonNull protected @NonNull MqttPayloadSerDes<Long> getLongSerDes()
      Returns:
      The serDes that handles Long
    • getFloatSerDes

      @NonNull protected @NonNull MqttPayloadSerDes<Float> getFloatSerDes()
      Returns:
      The serDes that handles Float
    • getDoubleSerDes

      @NonNull protected @NonNull MqttPayloadSerDes<Double> getDoubleSerDes()
      Returns:
      The serDes that handles Double
    • getByteArraySerDes

      @NonNull protected @NonNull MqttPayloadSerDes<byte[]> getByteArraySerDes()
      Returns:
      The serDes that handles byte[]
    • getByteBufferSerDes

      @NonNull protected @NonNull MqttPayloadSerDes<ByteBuffer> getByteBufferSerDes()
      Returns:
      The serDes that handles ByteBuffer
    • getUUIDSerDes

      @NonNull protected @NonNull MqttPayloadSerDes<UUID> getUUIDSerDes()
      Returns:
      The serDes that handles UUID
    • getBooleanSerDes

      @NonNull protected @NonNull MqttPayloadSerDes<Boolean> getBooleanSerDes()
      Returns:
      The serDes that handles UUID