Class DelegatingDecoder

java.lang.Object
io.micronaut.serde.DelegatingDecoder
All Implemented Interfaces:
Decoder, AutoCloseable

@Internal public abstract class DelegatingDecoder extends Object implements Decoder
Decoder that delegates to another decoder.
Since:
2.3.0
Author:
Jonas Konrad
  • Constructor Details

    • DelegatingDecoder

      public DelegatingDecoder()
  • Method Details

    • delegate

      protected abstract Decoder delegate() throws IOException
      Throws:
      IOException
    • delegateForDecodeValue

      public Decoder delegateForDecodeValue() throws IOException
      Returns:
      The delegated decode value
      Throws:
      IOException
    • decodeArray

      @NonNull public @NonNull Decoder decodeArray(io.micronaut.core.type.Argument<?> type) throws IOException
      Description copied from interface: Decoder
      Start decoding an array.
      Specified by:
      decodeArray in interface Decoder
      Parameters:
      type - The array type
      Returns:
      The array decoder
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeArray

      @NonNull public @NonNull Decoder decodeArray() throws IOException
      Description copied from interface: Decoder
      Start decoding an array.
      Specified by:
      decodeArray in interface Decoder
      Returns:
      The array decoder
      Throws:
      IOException - If an unrecoverable error occurs
    • hasNextArrayValue

      public boolean hasNextArrayValue() throws IOException
      Specified by:
      hasNextArrayValue in interface Decoder
      Returns:
      Returns true if another array value is available.
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeObject

      @NonNull public @NonNull Decoder decodeObject(@NonNull @NonNull io.micronaut.core.type.Argument<?> type) throws IOException
      Description copied from interface: Decoder
      Decodes an object.
      Specified by:
      decodeObject in interface Decoder
      Parameters:
      type - The type, never null
      Returns:
      The object decoder
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeObject

      @NonNull public @NonNull Decoder decodeObject() throws IOException
      Description copied from interface: Decoder
      Decodes an object.
      Specified by:
      decodeObject in interface Decoder
      Returns:
      The object decoder
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeKey

      @Nullable public @Nullable String decodeKey() throws IOException
      Description copied from interface: Decoder
      Decodes a key, if there are no more keys to decode returns null.
      Specified by:
      decodeKey in interface Decoder
      Returns:
      The key or null if there aren't any more keys
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeString

      @NonNull public @NonNull String decodeString() throws IOException
      Description copied from interface: Decoder
      Decodes a string.
      Specified by:
      decodeString in interface Decoder
      Returns:
      The string, never null
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeStringNullable

      @Nullable public @Nullable String decodeStringNullable() throws IOException
      Description copied from interface: Decoder
      Equivalent to decodeNull() ? null : decodeString().
      Specified by:
      decodeStringNullable in interface Decoder
      Returns:
      The value
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBoolean

      public boolean decodeBoolean() throws IOException
      Description copied from interface: Decoder
      Decodes a boolean.
      Specified by:
      decodeBoolean in interface Decoder
      Returns:
      The boolean
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBooleanNullable

      @Nullable public @Nullable Boolean decodeBooleanNullable() throws IOException
      Description copied from interface: Decoder
      Equivalent to decodeNull() ? null : decodeBoolean().
      Specified by:
      decodeBooleanNullable in interface Decoder
      Returns:
      The boolean
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeByte

      public byte decodeByte() throws IOException
      Description copied from interface: Decoder
      Decodes a byte.
      Specified by:
      decodeByte in interface Decoder
      Returns:
      The byte
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeByteNullable

      @Nullable public @Nullable Byte decodeByteNullable() throws IOException
      Description copied from interface: Decoder
      Equivalent to decodeNull() ? null : decodeByte().
      Specified by:
      decodeByteNullable in interface Decoder
      Returns:
      The value
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeShort

      public short decodeShort() throws IOException
      Description copied from interface: Decoder
      Decodes a short.
      Specified by:
      decodeShort in interface Decoder
      Returns:
      The short
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeShortNullable

      @Nullable public @Nullable Short decodeShortNullable() throws IOException
      Description copied from interface: Decoder
      Equivalent to decodeNull() ? null : decodeShort().
      Specified by:
      decodeShortNullable in interface Decoder
      Returns:
      The value
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeChar

      public char decodeChar() throws IOException
      Description copied from interface: Decoder
      Decodes a char.
      Specified by:
      decodeChar in interface Decoder
      Returns:
      The char
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeCharNullable

      @Nullable public @Nullable Character decodeCharNullable() throws IOException
      Description copied from interface: Decoder
      Equivalent to decodeNull() ? null : decodeChar().
      Specified by:
      decodeCharNullable in interface Decoder
      Returns:
      The value
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeInt

      public int decodeInt() throws IOException
      Description copied from interface: Decoder
      Decodes a int.
      Specified by:
      decodeInt in interface Decoder
      Returns:
      The int
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeIntNullable

      @Nullable public @Nullable Integer decodeIntNullable() throws IOException
      Description copied from interface: Decoder
      Equivalent to decodeNull() ? null : decodeInt().
      Specified by:
      decodeIntNullable in interface Decoder
      Returns:
      The int
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeLong

      public long decodeLong() throws IOException
      Description copied from interface: Decoder
      Decodes a long.
      Specified by:
      decodeLong in interface Decoder
      Returns:
      The long
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeLongNullable

      @Nullable public @Nullable Long decodeLongNullable() throws IOException
      Description copied from interface: Decoder
      Equivalent to decodeNull() ? null : decodeLong().
      Specified by:
      decodeLongNullable in interface Decoder
      Returns:
      The value
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeFloat

      public float decodeFloat() throws IOException
      Description copied from interface: Decoder
      Decodes a float.
      Specified by:
      decodeFloat in interface Decoder
      Returns:
      The float
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeFloatNullable

      @Nullable public @Nullable Float decodeFloatNullable() throws IOException
      Description copied from interface: Decoder
      Equivalent to decodeNull() ? null : decodeFloat().
      Specified by:
      decodeFloatNullable in interface Decoder
      Returns:
      The value
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeDouble

      public double decodeDouble() throws IOException
      Description copied from interface: Decoder
      Decodes a double.
      Specified by:
      decodeDouble in interface Decoder
      Returns:
      The double
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeDoubleNullable

      @Nullable public @Nullable Double decodeDoubleNullable() throws IOException
      Description copied from interface: Decoder
      Equivalent to decodeNull() ? null : decodeDouble().
      Specified by:
      decodeDoubleNullable in interface Decoder
      Returns:
      The value
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBigInteger

      @NonNull public @NonNull BigInteger decodeBigInteger() throws IOException
      Description copied from interface: Decoder
      Decodes a BigInteger.
      Specified by:
      decodeBigInteger in interface Decoder
      Returns:
      The BigInteger, never null
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBigIntegerNullable

      @Nullable public @Nullable BigInteger decodeBigIntegerNullable() throws IOException
      Description copied from interface: Decoder
      Equivalent to decodeNull() ? null : decodeBigInteger().
      Specified by:
      decodeBigIntegerNullable in interface Decoder
      Returns:
      The value
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBigDecimal

      @NonNull public @NonNull BigDecimal decodeBigDecimal() throws IOException
      Description copied from interface: Decoder
      Decodes a BigDecimal.
      Specified by:
      decodeBigDecimal in interface Decoder
      Returns:
      The BigDecimal, never null
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBigDecimalNullable

      @Nullable public @Nullable BigDecimal decodeBigDecimalNullable() throws IOException
      Description copied from interface: Decoder
      Equivalent to decodeNull() ? null : decodeBigDecimal().
      Specified by:
      decodeBigDecimalNullable in interface Decoder
      Returns:
      The value
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBinary

      public byte @NonNull [] decodeBinary() throws IOException
      Description copied from interface: Decoder
      Decode binary data from this stream. Binary data can be serialized in multiple different ways that differ by format.
      • An array of numbers must be supported by all implementations, for compatibility. This is also the default implementation.
      • A base64 string. This is convenient for text-based formats like json, and is supported by jackson.
      • A format-specific type, for binary formats such as bson.
      • Other format specific behavior. Oracle JDBC Json will parse strings as hex, for example.
      Implementations must support the array shape, but the other shapes are optional.
      Specified by:
      decodeBinary in interface Decoder
      Returns:
      The decoded byte array
      Throws:
      IOException
    • decodeBinaryNullable

      public byte @Nullable [] decodeBinaryNullable() throws IOException
      Description copied from interface: Decoder
      Equivalent to decodeNull() ? null : decodeBinary().
      Specified by:
      decodeBinaryNullable in interface Decoder
      Returns:
      The value
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeNull

      public boolean decodeNull() throws IOException
      Description copied from interface: Decoder
      Attempt to decode a null value. Returns false if this value is not null, and another method should be used for decoding. Returns true if this value was null, and the cursor has been advanced to the next value.
      Specified by:
      decodeNull in interface Decoder
      Returns:
      Returns true if the value was null
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeArbitrary

      @Nullable public @Nullable Object decodeArbitrary() throws IOException
      Description copied from interface: Decoder
      Decodes the current state into an arbitrary object.

      The following should be decoded by this method:

      • Object types will be decoded into a Map
      • Array types will be decoded into a List
      • JSON primitive types into the equivalent Java wrapper type
      Specified by:
      decodeArbitrary in interface Decoder
      Returns:
      The decoded object
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeNode

      @NonNull public @NonNull io.micronaut.json.tree.JsonNode decodeNode() throws IOException
      Description copied from interface: Decoder
      Decodes the current state into a JsonNode.
      Specified by:
      decodeNode in interface Decoder
      Returns:
      The decoded node
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBuffer

      public Decoder decodeBuffer() throws IOException
      Description copied from interface: Decoder
      Buffer the whole subtree of this value and return it as a new Decoder. The returned Decoder can be used independently to this Decoder. This means actual parsing of the subtree can be delayed.

      The returned Decoder should behave identically to this Decoder. This means that for example decoder.decodeDouble() should be equivalent to decoder.decodeBuffer().decodeDouble().

      Specified by:
      decodeBuffer in interface Decoder
      Returns:
      An independent decoder that visits this subtree.
      Throws:
      IOException - If an unrecoverable error occurs
    • skipValue

      public void skipValue() throws IOException
      Description copied from interface: Decoder
      Skips the current value.
      Specified by:
      skipValue in interface Decoder
      Throws:
      IOException - If an unrecoverable error occurs
    • finishStructure

      public void finishStructure() throws IOException
      Specified by:
      finishStructure in interface Decoder
      Throws:
      IOException - If an unrecoverable error occurs
    • finishStructure

      public void finishStructure(boolean consumeLeftElements) throws IOException
      Specified by:
      finishStructure in interface Decoder
      Parameters:
      consumeLeftElements - True to consume left elements
      Throws:
      IOException - If an unrecoverable error occurs
    • close

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

      @NonNull public abstract @NonNull IOException createDeserializationException(@NonNull @NonNull String message, @Nullable @Nullable Object invalidValue)
      This method remains abstract because it doesn't throw IOException and thus can't call decoder().
      Creates an exception for the given message.
      Specified by:
      createDeserializationException in interface Decoder
      Parameters:
      message - The message, never null
      invalidValue - The invalid value. Can be null.
      Returns:
      The exception, never null