Class JavaLangNatsMessageSerDes

java.lang.Object
io.micronaut.nats.serdes.JavaLangNatsMessageSerDes
All Implemented Interfaces:
io.micronaut.core.order.Ordered, NatsMessageSerDes<Object>

@Singleton public class JavaLangNatsMessageSerDes extends Object implements NatsMessageSerDes<Object>
Serializes and deserializes standard Java types.
Since:
1.0.0
Author:
jgrimm
  • Field Details

  • Constructor Details

    • JavaLangNatsMessageSerDes

      public JavaLangNatsMessageSerDes()
      Default constructor.
  • Method Details

    • serialize

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

      public Object deserialize(io.nats.client.Message message, io.micronaut.core.type.Argument<Object> argument)
      Description copied from interface: NatsMessageSerDes
      Deserializes the message into the requested type.
      Specified by:
      deserialize in interface NatsMessageSerDes<Object>
      Parameters:
      message - 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: NatsMessageSerDes
      Determines if this serdes supports the given type.
      Specified by:
      supports in interface NatsMessageSerDes<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 NatsMessageSerDes 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 NatsMessageSerDes<String> getStringSerDes()
      Returns:
      The serDes that handles String
    • getShortSerDes

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

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

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

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

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

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

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

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

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