Package io.micronaut.serde.support.util
Class JsonNodeEncoder
java.lang.Object
io.micronaut.serde.LimitingStream
io.micronaut.serde.support.util.JsonNodeEncoder
- All Implemented Interfaces:
Encoder,AutoCloseable
Implementation of the
Encoder interface that encodes a
in-memory JsonNode.-
Nested Class Summary
Nested classes/interfaces inherited from class io.micronaut.serde.LimitingStream
LimitingStream.RemainingLimits -
Field Summary
Fields inherited from class io.micronaut.serde.LimitingStream
DEFAULT_LIMITS, DEFAULT_MAXIMUM_DEPTH -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull JsonNodeEncodercreate()Creates a new instance.static @NonNull JsonNodeEncodercreate(LimitingStream.RemainingLimits limits) Creates a new instance.encodeArray(io.micronaut.core.type.Argument<?> type) Encodes an array.voidencodeBigDecimal(BigDecimal value) Encode a BigDecimal.voidencodeBigInteger(BigInteger value) Encode a BigInteger.voidencodeBinary(byte @NonNull [] data) Encode the given binary data.voidencodeBoolean(boolean value) Encode a boolean.voidencodeByte(byte value) Encode a byte.voidencodeChar(char value) Encode a char.voidencodeDouble(double value) Encode a double.voidencodeFloat(float value) Encode a float.voidencodeInt(int value) Encode an int.voidencodeLong(long value) Encode a long.voidEncodenull.encodeObject(io.micronaut.core.type.Argument<?> type) Encodes an object.voidencodeShort(short value) Encode a short.voidencodeString(String value) Encode a string.protected abstract voidencodeValue(io.micronaut.json.tree.JsonNode node) Encode the given value.@NonNull io.micronaut.json.tree.JsonNodeObtains the completed value.Methods inherited from class io.micronaut.serde.LimitingStream
childLimits, decreaseDepth, increaseDepth, limitsFromConfiguration, ourLimitsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.serde.Encoder
close, currentPath, encodeKey, finishStructure
-
Method Details
-
create
Creates a new instance.- Returns:
- The
JsonNodeEncoder
-
create
@NonNull @Internal public static @NonNull JsonNodeEncoder create(LimitingStream.RemainingLimits limits) Creates a new instance.- Parameters:
limits- The limits- 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:EncoderEncode a string.- Specified by:
encodeStringin interfaceEncoder- Parameters:
value- The string, nevernull
-
encodeBoolean
public void encodeBoolean(boolean value) Description copied from interface:EncoderEncode a boolean.- Specified by:
encodeBooleanin interfaceEncoder- Parameters:
value- The boolean
-
encodeByte
public void encodeByte(byte value) Description copied from interface:EncoderEncode a byte.- Specified by:
encodeBytein interfaceEncoder- Parameters:
value- The byte
-
encodeShort
public void encodeShort(short value) Description copied from interface:EncoderEncode a short.- Specified by:
encodeShortin interfaceEncoder- Parameters:
value- The short
-
encodeChar
public void encodeChar(char value) Description copied from interface:EncoderEncode a char.- Specified by:
encodeCharin interfaceEncoder- Parameters:
value- The char
-
encodeInt
public void encodeInt(int value) Description copied from interface:EncoderEncode an int. -
encodeLong
public void encodeLong(long value) Description copied from interface:EncoderEncode a long.- Specified by:
encodeLongin interfaceEncoder- Parameters:
value- The long
-
encodeFloat
public void encodeFloat(float value) Description copied from interface:EncoderEncode a float.- Specified by:
encodeFloatin interfaceEncoder- Parameters:
value- The float
-
encodeDouble
public void encodeDouble(double value) Description copied from interface:EncoderEncode a double.- Specified by:
encodeDoublein interfaceEncoder- Parameters:
value- The double
-
encodeBigInteger
Description copied from interface:EncoderEncode a BigInteger.- Specified by:
encodeBigIntegerin interfaceEncoder- Parameters:
value- The BigInteger, nevernull
-
encodeBigDecimal
Description copied from interface:EncoderEncode a BigDecimal.- Specified by:
encodeBigDecimalin interfaceEncoder- Parameters:
value- The BigDecimal, nevernull
-
encodeBinary
Description copied from interface:EncoderEncode the given binary data. The shape of the data in the output is unspecified, the only requirement is that the equivalentDecoder.decodeBinary()must be able to parse to the same data.- Specified by:
encodeBinaryin interfaceEncoder- Parameters:
data- The input data- Throws:
IOException
-
encodeNull
public void encodeNull()Description copied from interface:EncoderEncodenull.- Specified by:
encodeNullin interfaceEncoder
-
encodeArray
Description copied from interface:EncoderEncodes an array.- Specified by:
encodeArrayin interfaceEncoder- Parameters:
type- The array type, nevernull- Returns:
- The encoder, never
null - Throws:
SerdeException
-
encodeObject
Description copied from interface:EncoderEncodes an object.- Specified by:
encodeObjectin interfaceEncoder- Parameters:
type- The object type, nevernull- Returns:
- The encoder, never
null - Throws:
SerdeException
-
getCompletedValue
@NonNull public @NonNull io.micronaut.json.tree.JsonNode getCompletedValue()Obtains the completed value.- Returns:
- The materialized
JsonNode
-