Package io.micronaut.serde.jackson
Class JacksonDecoder
java.lang.Object
io.micronaut.serde.jackson.JacksonDecoder
- All Implemented Interfaces:
Decoder,AutoCloseable
Implementation of the
Decoder interface for Jackson.- Author:
- Denis Stepanov
-
Method Summary
Modifier and TypeMethodDescriptionstatic Decodercreate(com.fasterxml.jackson.core.JsonParser parser) createDeserializationException(String message, Object invalidValue) Creates an exception for the given message.Decodes the current state into an arbitrary object.Start decoding an array.decodeArray(io.micronaut.core.type.Argument<?> type) Start decoding an array.Decodes a BigDecimal.Equivalent todecodeNull() ? null : decodeBigDecimal().Decodes a BigInteger.Equivalent todecodeNull() ? null : decodeBigInteger().booleanDecodes a boolean.Equivalent todecodeNull() ? null : decodeBoolean().Buffer the whole subtree of this value and return it as a newDecoder.byteDecodes a byte.Equivalent todecodeNull() ? null : decodeByte().charDecodes a char.Equivalent todecodeNull() ? null : decodeChar().doubleDecodes a double.Equivalent todecodeNull() ? null : decodeDouble().floatDecodes a float.Equivalent todecodeNull() ? null : decodeFloat().intDecodes a int.Equivalent todecodeNull() ? null : decodeInt().Decodes a key, if there are no more keys to decode returnsnull.longDecodes a long.Equivalent todecodeNull() ? null : decodeLong().io.micronaut.json.tree.JsonNodeDecodes the current state into aJsonNode.booleanAttempt to decode a null value.Decodes an object.decodeObject(io.micronaut.core.type.Argument<?> type) Decodes an object.shortDecodes a short.Equivalent todecodeNull() ? null : decodeShort().Decodes a string.Equivalent todecodeNull() ? null : decodeString().voidvoidfinishStructure(boolean consumeLeftElements) booleanvoidSkips the current value.
-
Method Details
-
create
- Throws:
IOException
-
createDeserializationException
Description copied from interface:DecoderCreates an exception for the given message.- Specified by:
createDeserializationExceptionin interfaceDecoder- Parameters:
message- The message, nevernullinvalidValue- The invalid value. Can benull.- Returns:
- The exception, never
null
-
finishStructure
- Specified by:
finishStructurein interfaceDecoder- Parameters:
consumeLeftElements- True to consume left elements- Throws:
IOException- If an unrecoverable error occurs
-
finishStructure
- Specified by:
finishStructurein interfaceDecoder- Throws:
IOException- If an unrecoverable error occurs
-
hasNextArrayValue
- Specified by:
hasNextArrayValuein interfaceDecoder- Returns:
- Returns
trueif another array value is available. - Throws:
IOException- If an unrecoverable error occurs
-
decodeKey
Description copied from interface:DecoderDecodes a key, if there are no more keys to decode returnsnull.- Specified by:
decodeKeyin interfaceDecoder- Returns:
- The key or
nullif there aren't any more keys - Throws:
IOException- If an unrecoverable error occurs
-
decodeArray
@NonNull public JacksonDecoder decodeArray(io.micronaut.core.type.Argument<?> type) throws IOException Description copied from interface:DecoderStart decoding an array.- Specified by:
decodeArrayin interfaceDecoder- Parameters:
type- The array type- Returns:
- The array decoder
- Throws:
IOException- If an unrecoverable error occurs
-
decodeArray
Description copied from interface:DecoderStart decoding an array.- Specified by:
decodeArrayin interfaceDecoder- Returns:
- The array decoder
- Throws:
IOException- If an unrecoverable error occurs
-
decodeObject
@NonNull public JacksonDecoder decodeObject(io.micronaut.core.type.Argument<?> type) throws IOException Description copied from interface:DecoderDecodes an object.- Specified by:
decodeObjectin interfaceDecoder- Parameters:
type- The type, nevernull- Returns:
- The object decoder
- Throws:
IOException- If an unrecoverable error occurs
-
decodeObject
Description copied from interface:DecoderDecodes an object.- Specified by:
decodeObjectin interfaceDecoder- Returns:
- The object decoder
- Throws:
IOException- If an unrecoverable error occurs
-
decodeString
Description copied from interface:DecoderDecodes a string.- Specified by:
decodeStringin interfaceDecoder- Returns:
- The string, never
null - Throws:
IOException- If an unrecoverable error occurs
-
decodeStringNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeString().- Specified by:
decodeStringNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeBoolean
Description copied from interface:DecoderDecodes a boolean.- Specified by:
decodeBooleanin interfaceDecoder- Returns:
- The boolean
- Throws:
IOException- If an unrecoverable error occurs
-
decodeBooleanNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeBoolean().- Specified by:
decodeBooleanNullablein interfaceDecoder- Returns:
- The boolean
- Throws:
IOException- If an unrecoverable error occurs
-
decodeByte
Description copied from interface:DecoderDecodes a byte.- Specified by:
decodeBytein interfaceDecoder- Returns:
- The byte
- Throws:
IOException- If an unrecoverable error occurs
-
decodeByteNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeByte().- Specified by:
decodeByteNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeShort
Description copied from interface:DecoderDecodes a short.- Specified by:
decodeShortin interfaceDecoder- Returns:
- The short
- Throws:
IOException- If an unrecoverable error occurs
-
decodeShortNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeShort().- Specified by:
decodeShortNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeChar
Description copied from interface:DecoderDecodes a char.- Specified by:
decodeCharin interfaceDecoder- Returns:
- The char
- Throws:
IOException- If an unrecoverable error occurs
-
decodeCharNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeChar().- Specified by:
decodeCharNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeInt
Description copied from interface:DecoderDecodes a int.- Specified by:
decodeIntin interfaceDecoder- Returns:
- The int
- Throws:
IOException- If an unrecoverable error occurs
-
decodeIntNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeInt().- Specified by:
decodeIntNullablein interfaceDecoder- Returns:
- The int
- Throws:
IOException- If an unrecoverable error occurs
-
decodeLong
Description copied from interface:DecoderDecodes a long.- Specified by:
decodeLongin interfaceDecoder- Returns:
- The long
- Throws:
IOException- If an unrecoverable error occurs
-
decodeLongNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeLong().- Specified by:
decodeLongNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeFloat
Description copied from interface:DecoderDecodes a float.- Specified by:
decodeFloatin interfaceDecoder- Returns:
- The float
- Throws:
IOException- If an unrecoverable error occurs
-
decodeFloatNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeFloat().- Specified by:
decodeFloatNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeDouble
Description copied from interface:DecoderDecodes a double.- Specified by:
decodeDoublein interfaceDecoder- Returns:
- The double
- Throws:
IOException- If an unrecoverable error occurs
-
decodeDoubleNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeDouble().- Specified by:
decodeDoubleNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeBigInteger
Description copied from interface:DecoderDecodes a BigInteger.- Specified by:
decodeBigIntegerin interfaceDecoder- Returns:
- The BigInteger, never
null - Throws:
IOException- If an unrecoverable error occurs
-
decodeBigIntegerNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeBigInteger().- Specified by:
decodeBigIntegerNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeBigDecimal
Description copied from interface:DecoderDecodes a BigDecimal.- Specified by:
decodeBigDecimalin interfaceDecoder- Returns:
- The BigDecimal, never
null - Throws:
IOException- If an unrecoverable error occurs
-
decodeBigDecimalNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeBigDecimal().- Specified by:
decodeBigDecimalNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeNull
Description copied from interface:DecoderAttempt to decode a null value. Returnsfalseif this value is not null, and another method should be used for decoding. Returnstrueif this value was null, and the cursor has been advanced to the next value.- Specified by:
decodeNullin interfaceDecoder- Returns:
- Returns
trueif the value wasnull - Throws:
IOException- If an unrecoverable error occurs
-
decodeBuffer
Description copied from interface:DecoderBuffer the whole subtree of this value and return it as a newDecoder. The returnedDecodercan be used independently to thisDecoder. This means actual parsing of the subtree can be delayed.The returned
Decodershould behave identically to thisDecoder. This means that for exampledecoder.decodeDouble()should be equivalent todecoder.decodeBuffer().decodeDouble().- Specified by:
decodeBufferin interfaceDecoder- Returns:
- An independent decoder that visits this subtree.
- Throws:
IOException- If an unrecoverable error occurs
-
decodeNode
Description copied from interface:DecoderDecodes the current state into aJsonNode.- Specified by:
decodeNodein interfaceDecoder- Returns:
- The decoded node
- Throws:
IOException- If an unrecoverable error occurs
-
decodeArbitrary
Description copied from interface:DecoderDecodes the current state into an arbitrary object.The following should be decoded by this method:
- Specified by:
decodeArbitraryin interfaceDecoder- Returns:
- The decoded object
- Throws:
IOException- If an unrecoverable error occurs
-
skipValue
Description copied from interface:DecoderSkips the current value.- Specified by:
skipValuein interfaceDecoder- Throws:
IOException- If an unrecoverable error occurs
-