Class JacksonEncoder

java.lang.Object
io.micronaut.serde.LimitingStream
io.micronaut.serde.jackson.JacksonEncoder
All Implemented Interfaces:
Encoder, AutoCloseable

public abstract class JacksonEncoder extends LimitingStream implements Encoder
Implementation of the Encoder interface for Jackson.
  • Field Details

    • generator

      protected final com.fasterxml.jackson.core.JsonGenerator generator
  • Method Details

    • create

      @NonNull public static @NonNull Encoder create(@NonNull @NonNull com.fasterxml.jackson.core.JsonGenerator generator)
    • create

      @NonNull @Internal public static @NonNull Encoder create(@NonNull @NonNull com.fasterxml.jackson.core.JsonGenerator generator, @NonNull @NonNull LimitingStream.RemainingLimits remainingLimits)
      Create a new encoder.
      Parameters:
      generator - The jackson-core generator to write to
      remainingLimits - The maximum nesting depth
      Returns:
      The encoder
    • encodeArray

      public final Encoder encodeArray(io.micronaut.core.type.Argument<?> type) throws IOException
      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:
      IOException - if an error occurs
    • encodeObject

      public final Encoder encodeObject(io.micronaut.core.type.Argument<?> type) throws IOException
      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:
      IOException - if an error occurs
    • finishStructure

      public final void finishStructure() throws IOException
      Description copied from interface: Encoder
      Finalize a previously created structure, like an array or object.
      Specified by:
      finishStructure in interface Encoder
      Throws:
      IOException - If an error occurs
    • close

      public final void close() throws IOException
      Description copied from interface: Encoder
      Finalize the current structure. Equivalent to calling Encoder.finishStructure().
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Encoder
      Throws:
      IOException - If an unrecoverable error occurs
    • finishStructureToken

      protected abstract void finishStructureToken() throws IOException
      Throws:
      IOException
    • currentPath

      public String currentPath()
      Description copied from interface: Encoder
      Return an analysis of the current path.
      Specified by:
      currentPath in interface Encoder
      Returns:
      The current path if known
    • encodeKey

      public final void encodeKey(@NonNull @NonNull String key) throws IOException
      Description copied from interface: Encoder
      Encode a key.
      Specified by:
      encodeKey in interface Encoder
      Parameters:
      key - The key, never null
      Throws:
      IOException - If an error occurs
    • encodeString

      public final void encodeString(@NonNull @NonNull String value) throws IOException
      Description copied from interface: Encoder
      Encode a string.
      Specified by:
      encodeString in interface Encoder
      Parameters:
      value - The string, never null
      Throws:
      IOException - If an error occurs
    • encodeBoolean

      public final void encodeBoolean(boolean value) throws IOException
      Description copied from interface: Encoder
      Encode a boolean.
      Specified by:
      encodeBoolean in interface Encoder
      Parameters:
      value - The boolean
      Throws:
      IOException - If an error occurs
    • encodeByte

      public final void encodeByte(byte value) throws IOException
      Description copied from interface: Encoder
      Encode a byte.
      Specified by:
      encodeByte in interface Encoder
      Parameters:
      value - The byte
      Throws:
      IOException - If an error occurs
    • encodeShort

      public final void encodeShort(short value) throws IOException
      Description copied from interface: Encoder
      Encode a short.
      Specified by:
      encodeShort in interface Encoder
      Parameters:
      value - The short
      Throws:
      IOException - If an error occurs
    • encodeChar

      public final void encodeChar(char value) throws IOException
      Description copied from interface: Encoder
      Encode a char.
      Specified by:
      encodeChar in interface Encoder
      Parameters:
      value - The char
      Throws:
      IOException - If an error occurs
    • encodeInt

      public final void encodeInt(int value) throws IOException
      Description copied from interface: Encoder
      Encode an int.
      Specified by:
      encodeInt in interface Encoder
      Parameters:
      value - The int
      Throws:
      IOException - If an error occurs
    • encodeLong

      public final void encodeLong(long value) throws IOException
      Description copied from interface: Encoder
      Encode a long.
      Specified by:
      encodeLong in interface Encoder
      Parameters:
      value - The long
      Throws:
      IOException - If an error occurs
    • encodeFloat

      public final void encodeFloat(float value) throws IOException
      Description copied from interface: Encoder
      Encode a float.
      Specified by:
      encodeFloat in interface Encoder
      Parameters:
      value - The float
      Throws:
      IOException - If an error occurs
    • encodeDouble

      public final void encodeDouble(double value) throws IOException
      Description copied from interface: Encoder
      Encode a double.
      Specified by:
      encodeDouble in interface Encoder
      Parameters:
      value - The double
      Throws:
      IOException - If an error occurs
    • encodeBigInteger

      public final void encodeBigInteger(@NonNull @NonNull BigInteger value) throws IOException
      Description copied from interface: Encoder
      Encode a BigInteger.
      Specified by:
      encodeBigInteger in interface Encoder
      Parameters:
      value - The BigInteger, never null
      Throws:
      IOException - If an error occurs
    • encodeBigDecimal

      public final void encodeBigDecimal(@NonNull @NonNull BigDecimal value) throws IOException
      Description copied from interface: Encoder
      Encode a BigDecimal.
      Specified by:
      encodeBigDecimal in interface Encoder
      Parameters:
      value - The BigDecimal, never null
      Throws:
      IOException - If an error occurs
    • 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 final void encodeNull() throws IOException
      Description copied from interface: Encoder
      Encode null.
      Specified by:
      encodeNull in interface Encoder
      Throws:
      IOException - If an error occurs