Package io.micronaut.serde.support.util
Class JsonNodeEncoder
java.lang.Object
io.micronaut.serde.support.util.JsonNodeEncoder
- All Implemented Interfaces:
Encoder
,AutoCloseable
Implementation of the
Encoder
interface that encodes a
in-memory JsonNode
.-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull JsonNodeEncoder
create()
Creates a new instance.encodeArray
(io.micronaut.core.type.Argument<?> type) Encodes an array.void
encodeBigDecimal
(BigDecimal value) Encode a BigDecimal.void
encodeBigInteger
(BigInteger value) Encode a BigInteger.void
encodeBoolean
(boolean value) Encode a boolean.void
encodeByte
(byte value) Encode a byte.void
encodeChar
(char value) Encode a char.void
encodeDouble
(double value) Encode a double.void
encodeFloat
(float value) Encode a float.void
encodeInt
(int value) Encode an int.void
encodeLong
(long value) Encode a long.void
Encodenull
.encodeObject
(io.micronaut.core.type.Argument<?> type) Encodes an object.void
encodeShort
(short value) Encode a short.void
encodeString
(String value) Encode a string.protected abstract void
encodeValue
(io.micronaut.json.tree.JsonNode node) Encode the given value.@NonNull io.micronaut.json.tree.JsonNode
Obtains the completed 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.Encoder
close, currentPath, encodeKey, finishStructure
-
Method Details
-
create
Creates a new instance.- 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
Description copied from interface:Encoder
Encode a string.- Specified by:
encodeString
in interfaceEncoder
- Parameters:
value
- The string, nevernull
-
encodeBoolean
public void encodeBoolean(boolean value) Description copied from interface:Encoder
Encode a boolean.- Specified by:
encodeBoolean
in interfaceEncoder
- Parameters:
value
- The boolean
-
encodeByte
public void encodeByte(byte value) Description copied from interface:Encoder
Encode a byte.- Specified by:
encodeByte
in interfaceEncoder
- Parameters:
value
- The byte
-
encodeShort
public void encodeShort(short value) Description copied from interface:Encoder
Encode a short.- Specified by:
encodeShort
in interfaceEncoder
- Parameters:
value
- The short
-
encodeChar
public void encodeChar(char value) Description copied from interface:Encoder
Encode a char.- Specified by:
encodeChar
in interfaceEncoder
- Parameters:
value
- The char
-
encodeInt
public void encodeInt(int value) Description copied from interface:Encoder
Encode an int. -
encodeLong
public void encodeLong(long value) Description copied from interface:Encoder
Encode a long.- Specified by:
encodeLong
in interfaceEncoder
- Parameters:
value
- The long
-
encodeFloat
public void encodeFloat(float value) Description copied from interface:Encoder
Encode a float.- Specified by:
encodeFloat
in interfaceEncoder
- Parameters:
value
- The float
-
encodeDouble
public void encodeDouble(double value) Description copied from interface:Encoder
Encode a double.- Specified by:
encodeDouble
in interfaceEncoder
- Parameters:
value
- The double
-
encodeBigInteger
Description copied from interface:Encoder
Encode a BigInteger.- Specified by:
encodeBigInteger
in interfaceEncoder
- Parameters:
value
- The BigInteger, nevernull
-
encodeBigDecimal
Description copied from interface:Encoder
Encode a BigDecimal.- Specified by:
encodeBigDecimal
in interfaceEncoder
- Parameters:
value
- The BigDecimal, nevernull
-
encodeNull
public void encodeNull()Description copied from interface:Encoder
Encodenull
.- Specified by:
encodeNull
in interfaceEncoder
-
encodeArray
Description copied from interface:Encoder
Encodes an array.- Specified by:
encodeArray
in interfaceEncoder
- Parameters:
type
- The array type, nevernull
- Returns:
- The encoder, never
null
-
encodeObject
Description copied from interface:Encoder
Encodes an object.- Specified by:
encodeObject
in interfaceEncoder
- Parameters:
type
- The object type, nevernull
- Returns:
- The encoder, never
null
-
getCompletedValue
@NonNull public @NonNull io.micronaut.json.tree.JsonNode getCompletedValue()Obtains the completed value.- Returns:
- The materialized
JsonNode
-