Class JsonNodeEncoder

java.lang.Object
io.micronaut.serde.LimitingStream
io.micronaut.serde.support.util.JsonNodeEncoder
All Implemented Interfaces:
Encoder, AutoCloseable

public abstract class JsonNodeEncoder extends LimitingStream implements Encoder
Implementation of the Encoder interface that encodes a in-memory JsonNode.
  • Method Details

    • create

      @NonNull public static @NonNull JsonNodeEncoder create()
      Creates a new instance.
      Returns:
      The JsonNodeEncoder
    • create

      @NonNull @Internal public static @NonNull JsonNodeEncoder create(LimitingStream.RemainingLimits limits)
      Creates a new instance.
      Parameters:
      limits - The limits
      Returns:
      The JsonNodeEncoder
    • encodeValue

      protected abstract void encodeValue(io.micronaut.json.tree.JsonNode node)
      Encode the given value.
      Parameters:
      node - The node to encode
    • encodeString

      public void encodeString(String value)
      Description copied from interface: Encoder
      Encode a string.
      Specified by:
      encodeString in interface Encoder
      Parameters:
      value - The string, never null
    • encodeBoolean

      public void encodeBoolean(boolean value)
      Description copied from interface: Encoder
      Encode a boolean.
      Specified by:
      encodeBoolean in interface Encoder
      Parameters:
      value - The boolean
    • encodeByte

      public void encodeByte(byte value)
      Description copied from interface: Encoder
      Encode a byte.
      Specified by:
      encodeByte in interface Encoder
      Parameters:
      value - The byte
    • encodeShort

      public void encodeShort(short value)
      Description copied from interface: Encoder
      Encode a short.
      Specified by:
      encodeShort in interface Encoder
      Parameters:
      value - The short
    • encodeChar

      public void encodeChar(char value)
      Description copied from interface: Encoder
      Encode a char.
      Specified by:
      encodeChar in interface Encoder
      Parameters:
      value - The char
    • encodeInt

      public void encodeInt(int value)
      Description copied from interface: Encoder
      Encode an int.
      Specified by:
      encodeInt in interface Encoder
      Parameters:
      value - The int
    • encodeLong

      public void encodeLong(long value)
      Description copied from interface: Encoder
      Encode a long.
      Specified by:
      encodeLong in interface Encoder
      Parameters:
      value - The long
    • encodeFloat

      public void encodeFloat(float value)
      Description copied from interface: Encoder
      Encode a float.
      Specified by:
      encodeFloat in interface Encoder
      Parameters:
      value - The float
    • encodeDouble

      public void encodeDouble(double value)
      Description copied from interface: Encoder
      Encode a double.
      Specified by:
      encodeDouble in interface Encoder
      Parameters:
      value - The double
    • encodeBigInteger

      public void encodeBigInteger(BigInteger value)
      Description copied from interface: Encoder
      Encode a BigInteger.
      Specified by:
      encodeBigInteger in interface Encoder
      Parameters:
      value - The BigInteger, never null
    • encodeBigDecimal

      public void encodeBigDecimal(BigDecimal value)
      Description copied from interface: Encoder
      Encode a BigDecimal.
      Specified by:
      encodeBigDecimal in interface Encoder
      Parameters:
      value - The BigDecimal, never null
    • encodeBinary

      public void encodeBinary(byte @NonNull [] data) throws IOException
      Description copied from interface: Encoder
      Encode the given binary data. The shape of the data in the output is unspecified, the only requirement is that the equivalent Decoder.decodeBinary() must be able to parse to the same data.
      Specified by:
      encodeBinary in interface Encoder
      Parameters:
      data - The input data
      Throws:
      IOException
    • encodeNull

      public void encodeNull()
      Description copied from interface: Encoder
      Encode null.
      Specified by:
      encodeNull in interface Encoder
    • encodeArray

      public Encoder encodeArray(io.micronaut.core.type.Argument<?> type) throws SerdeException
      Description copied from interface: Encoder
      Encodes an array.
      Specified by:
      encodeArray in interface Encoder
      Parameters:
      type - The array type, never null
      Returns:
      The encoder, never null
      Throws:
      SerdeException
    • encodeObject

      public Encoder encodeObject(io.micronaut.core.type.Argument<?> type) throws SerdeException
      Description copied from interface: Encoder
      Encodes an object.
      Specified by:
      encodeObject in interface Encoder
      Parameters:
      type - The object type, never null
      Returns:
      The encoder, never null
      Throws:
      SerdeException
    • getCompletedValue

      @NonNull public @NonNull io.micronaut.json.tree.JsonNode getCompletedValue()
      Obtains the completed value.
      Returns:
      The materialized JsonNode