Package io.micronaut.serde
Class DelegatingDecoder
java.lang.Object
io.micronaut.serde.DelegatingDecoder
- All Implemented Interfaces:
Decoder
,AutoCloseable
Decoder that delegates to another decoder.
- Since:
- 2.3.0
- Author:
- Jonas Konrad
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Finalize the current structure.abstract @NonNull IOException
createDeserializationException
(@NonNull String message, @Nullable Object invalidValue) This method remains abstract because it doesn't throw IOException and thus can't call decoder().@Nullable Object
Decodes the current state into an arbitrary object.@NonNull Decoder
Start decoding an array.@NonNull Decoder
decodeArray
(io.micronaut.core.type.Argument<?> type) Start decoding an array.@NonNull BigDecimal
Decodes a BigDecimal.@Nullable BigDecimal
Equivalent todecodeNull() ? null : decodeBigDecimal()
.@NonNull BigInteger
Decodes a BigInteger.@Nullable BigInteger
Equivalent todecodeNull() ? null : decodeBigInteger()
.byte @NonNull []
Decode binary data from this stream.byte @Nullable []
Equivalent todecodeNull() ? null : decodeBinary()
.boolean
Decodes a boolean.@Nullable Boolean
Equivalent todecodeNull() ? null : decodeBoolean()
.Buffer the whole subtree of this value and return it as a newDecoder
.byte
Decodes a byte.@Nullable Byte
Equivalent todecodeNull() ? null : decodeByte()
.char
Decodes a char.@Nullable Character
Equivalent todecodeNull() ? null : decodeChar()
.double
Decodes a double.@Nullable Double
Equivalent todecodeNull() ? null : decodeDouble()
.float
Decodes a float.@Nullable Float
Equivalent todecodeNull() ? null : decodeFloat()
.int
Decodes a int.@Nullable Integer
Equivalent todecodeNull() ? null : decodeInt()
.@Nullable String
Decodes a key, if there are no more keys to decode returnsnull
.long
Decodes a long.@Nullable Long
Equivalent todecodeNull() ? null : decodeLong()
.@NonNull io.micronaut.json.tree.JsonNode
Decodes the current state into aJsonNode
.boolean
Attempt to decode a null value.@NonNull Decoder
Decodes an object.@NonNull Decoder
decodeObject
(@NonNull io.micronaut.core.type.Argument<?> type) Decodes an object.short
Decodes a short.@Nullable Short
Equivalent todecodeNull() ? null : decodeShort()
.@NonNull String
Decodes a string.@Nullable String
Equivalent todecodeNull() ? null : decodeString()
.protected abstract Decoder
delegate()
void
void
finishStructure
(boolean consumeLeftElements) boolean
void
Skips the current value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.serde.Decoder
decodeNumber, decodeNumberNullable
-
Constructor Details
-
DelegatingDecoder
public DelegatingDecoder()
-
-
Method Details
-
delegate
- Throws:
IOException
-
delegateForDecodeValue
- 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 interfaceDecoder
- Parameters:
type
- The array type- Returns:
- The array decoder
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeArray
Description copied from interface:Decoder
Start decoding an array.- Specified by:
decodeArray
in interfaceDecoder
- Returns:
- The array decoder
- Throws:
IOException
- If an unrecoverable error occurs
-
hasNextArrayValue
- Specified by:
hasNextArrayValue
in interfaceDecoder
- 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 interfaceDecoder
- Parameters:
type
- The type, nevernull
- Returns:
- The object decoder
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeObject
Description copied from interface:Decoder
Decodes an object.- Specified by:
decodeObject
in interfaceDecoder
- Returns:
- The object decoder
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeKey
Description copied from interface:Decoder
Decodes a key, if there are no more keys to decode returnsnull
.- Specified by:
decodeKey
in interfaceDecoder
- Returns:
- The key or
null
if there aren't any more keys - Throws:
IOException
- If an unrecoverable error occurs
-
decodeString
Description copied from interface:Decoder
Decodes a string.- Specified by:
decodeString
in interfaceDecoder
- Returns:
- The string, never
null
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeStringNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeString()
.- Specified by:
decodeStringNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBoolean
Description copied from interface:Decoder
Decodes a boolean.- Specified by:
decodeBoolean
in interfaceDecoder
- Returns:
- The boolean
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBooleanNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeBoolean()
.- Specified by:
decodeBooleanNullable
in interfaceDecoder
- Returns:
- The boolean
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeByte
Description copied from interface:Decoder
Decodes a byte.- Specified by:
decodeByte
in interfaceDecoder
- Returns:
- The byte
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeByteNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeByte()
.- Specified by:
decodeByteNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeShort
Description copied from interface:Decoder
Decodes a short.- Specified by:
decodeShort
in interfaceDecoder
- Returns:
- The short
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeShortNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeShort()
.- Specified by:
decodeShortNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeChar
Description copied from interface:Decoder
Decodes a char.- Specified by:
decodeChar
in interfaceDecoder
- Returns:
- The char
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeCharNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeChar()
.- Specified by:
decodeCharNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeInt
Description copied from interface:Decoder
Decodes a int.- Specified by:
decodeInt
in interfaceDecoder
- Returns:
- The int
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeIntNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeInt()
.- Specified by:
decodeIntNullable
in interfaceDecoder
- Returns:
- The int
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeLong
Description copied from interface:Decoder
Decodes a long.- Specified by:
decodeLong
in interfaceDecoder
- Returns:
- The long
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeLongNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeLong()
.- Specified by:
decodeLongNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeFloat
Description copied from interface:Decoder
Decodes a float.- Specified by:
decodeFloat
in interfaceDecoder
- Returns:
- The float
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeFloatNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeFloat()
.- Specified by:
decodeFloatNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeDouble
Description copied from interface:Decoder
Decodes a double.- Specified by:
decodeDouble
in interfaceDecoder
- Returns:
- The double
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeDoubleNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeDouble()
.- Specified by:
decodeDoubleNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBigInteger
Description copied from interface:Decoder
Decodes a BigInteger.- Specified by:
decodeBigInteger
in interfaceDecoder
- Returns:
- The BigInteger, never
null
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBigIntegerNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeBigInteger()
.- Specified by:
decodeBigIntegerNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBigDecimal
Description copied from interface:Decoder
Decodes a BigDecimal.- Specified by:
decodeBigDecimal
in interfaceDecoder
- Returns:
- The BigDecimal, never
null
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBigDecimalNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeBigDecimal()
.- Specified by:
decodeBigDecimalNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBinary
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.
- Specified by:
decodeBinary
in interfaceDecoder
- Returns:
- The decoded byte array
- Throws:
IOException
-
decodeBinaryNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeBinary()
.- Specified by:
decodeBinaryNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeNull
Description copied from interface:Decoder
Attempt to decode a null value. Returnsfalse
if this value is not null, and another method should be used for decoding. Returnstrue
if this value was null, and the cursor has been advanced to the next value.- Specified by:
decodeNull
in interfaceDecoder
- Returns:
- Returns
true
if the value wasnull
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeArbitrary
Description copied from interface:Decoder
Decodes the current state into an arbitrary object.The following should be decoded by this method:
- Specified by:
decodeArbitrary
in interfaceDecoder
- Returns:
- The decoded object
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeNode
Description copied from interface:Decoder
Decodes the current state into aJsonNode
.- Specified by:
decodeNode
in interfaceDecoder
- Returns:
- The decoded node
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBuffer
Description copied from interface:Decoder
Buffer the whole subtree of this value and return it as a newDecoder
. The returnedDecoder
can be used independently to thisDecoder
. This means actual parsing of the subtree can be delayed.The returned
Decoder
should behave identically to thisDecoder
. This means that for exampledecoder.decodeDouble()
should be equivalent todecoder.decodeBuffer().decodeDouble()
.- Specified by:
decodeBuffer
in interfaceDecoder
- Returns:
- An independent decoder that visits this subtree.
- Throws:
IOException
- If an unrecoverable error occurs
-
skipValue
Description copied from interface:Decoder
Skips the current value.- Specified by:
skipValue
in interfaceDecoder
- Throws:
IOException
- If an unrecoverable error occurs
-
finishStructure
- Specified by:
finishStructure
in interfaceDecoder
- Throws:
IOException
- If an unrecoverable error occurs
-
finishStructure
- Specified by:
finishStructure
in interfaceDecoder
- Parameters:
consumeLeftElements
- True to consume left elements- Throws:
IOException
- If an unrecoverable error occurs
-
close
Description copied from interface:Decoder
Finalize the current structure. Equivalent to callingDecoder.finishStructure()
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDecoder
- 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 interfaceDecoder
- Parameters:
message
- The message, nevernull
invalidValue
- The invalid value. Can benull
.- Returns:
- The exception, never
null
-