java.lang.Object
tools.jackson.databind.JacksonSerializable.Base
tools.jackson.databind.JsonNode
tools.jackson.databind.node.BaseJsonNode
tools.jackson.databind.node.ValueNode
tools.jackson.databind.node.POJONode
- All Implemented Interfaces:
Serializable,Iterable<JsonNode>,tools.jackson.core.TreeNode,JacksonSerializable
Value node that contains a wrapped POJO, to be serialized as
a JSON constructed through data mapping (usually done by
calling
ObjectMapper).- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.JsonNode
JsonNode.OverwriteModeNested classes/interfaces inherited from interface tools.jackson.databind.JacksonSerializable
JacksonSerializable.Base -
Field Summary
FieldsFields inherited from class tools.jackson.databind.node.ValueNode
BD_MAX_INTEGER, BD_MAX_LONG, BD_MAX_SHORT, BD_MIN_INTEGER, BD_MIN_LONG, BD_MIN_SHORT, BI_MAX_INTEGER, BI_MAX_LONG, BI_MAX_SHORT, BI_MIN_INTEGER, BI_MIN_LONG, BI_MIN_SHORT, MISSINGFields inherited from class tools.jackson.databind.node.BaseJsonNode
OPT_FALSE, OPT_TRUE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected BooleanMethod sub-classes should override if they can producebooleanvalues viaBaseJsonNode.asBoolean()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).protected StringMethod sub-classes should override if they can produceStringvalues viaBaseJsonNode.asString()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).protected BigDecimalprotected BigIntegerprotected Doubleprotected Floatprotected Longprotected boolean_pojoEquals(POJONode other) protected StringMethod for implementation classes to return a short description of contained value, to be used in error messages.Method similar toJsonNode.bigIntegerValue()but in addition to coercing Number values (same asJsonNode.bigIntegerValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.bigIntegerValue()) will be truncated to integer value (like withBigDecimal.toBigInteger())) JSON Strings that represent JSON Numbers ("stringified" numbers) JSON Null (coerced toBigInteger.ZERO)) Missing node (coerced toBigInteger.ZERO)) POJO nodes that contain Number valuesasBigInteger(BigInteger defaultValue) Method similar toJsonNode.asBigInteger(), but that will return specifieddefaultValueif this node cannot be converted toBigIntegeror if the value isnull.Method similar toJsonNode.bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to JavaBigIntegeror if the value isnull.booleanasBoolean(boolean defaultValue) Similar toJsonNode.asBoolean(), but instead of throwing an exception for non-coercible values or coercingnull(or missing node), will return the specified default value.Similar toJsonNode.asBoolean(), but instead of throwing an exception for non-coercible values or coercingnull(or missing node), will returnOptional.empty().Method that will try to access value of this node as aBigDecimal: but if node value cannot be expressed exactly as aBigDecimal, aJsonNodeExceptionwill be thrown.asDecimal(BigDecimal defaultValue) Method similar toJsonNode.asDecimal(), but that will returndefaultValueif this node cannot be coerced to JavaBigDecimalor if the value isnull.Method similar toJsonNode.asDecimal(), but that will return emptyOptional(Optional.empty()) if this node cannot be coerced toBigDecimalor if the value isnull.doubleasDouble()Method similar toJsonNode.doubleValue()but in addition to coercing Number values will also try coerce couple of additional types: JSON String that represents JSON Numbers ("stringified" numbers) JSON Null (coerced to0.0d)) Missing node (coerced to0.0d)) POJO nodes that contain Number valuesdoubleasDouble(double defaultValue) Method similar toJsonNode.asDouble(), but that will returndefaultValueif this node cannot be coerced todoubleor if the value isnull.Method similar toJsonNode.asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced todoubleor if the value isnull.floatasFloat()Method similar toJsonNode.floatValue()but in addition to coercing Number values will also try coerce couple of additional types: JSON String that represents JSON Numbers ("stringified" numbers) JSON Null (coerced to0.0f)) Missing node (coerced to0.0f)) POJO nodes that contain Number valuesfloatasFloat(float defaultValue) Method similar toJsonNode.asFloat(), but that will returndefaultValueif this node cannot be coerced tofloator if the value isnull.Method similar toJsonNode.asFloat(), but that will return (Optional.empty()) if this node cannot be coerced tofloator if the value isnull.intasInt()Method similar toJsonNode.intValue()but in addition to coercing Number values (same asJsonNode.intValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.intValue()) will be truncated toint(if (and only if) they fit inintrange).intasInt(int defaultValue) Method similar toJsonNode.intValue(), but that will return specifieddefaultValueif this node cannot be converted tointor if the value isnull.asIntOpt()Method similar toJsonNode.asInt(), but that will return (OptionalInt.empty()) if this node cannot be coerced tointor if the value isnull.longasLong()Method similar toJsonNode.longValue()but in addition to coercing Number values (same asJsonNode.longValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.longValue()) will be truncated tolong(if (and only if) they fit inlongrange).longasLong(long defaultValue) Method similar toJsonNode.asLong(), but that will return specifieddefaultValueif this node cannot be coerced tolong(instead of throwing an exception) or if the value isnull.Method similar toJsonNode.asLong(), but that will return (OptionalLong.empty()) if this node cannot be coerced tolongor if the value isnull.shortasShort()Method similar toJsonNode.shortValue()but in addition to coercing Number values (same asJsonNode.shortValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.shortValue()) will be truncated toshort(if (and only if) they fit inshortrange).shortasShort(short defaultValue) Method similar toJsonNode.shortValue(), but that will return specifieddefaultValueif this node cannot be converted toshortor if the value isnull.Method similar toJsonNode.asShort(), but that will return (Optional.empty()) if this node cannot be coerced toshortor if the value isnull.Similar toJsonNode.asString(), but instead of throwing an exception for non-coercible values or coercingnull(or missing value), will return the specified default value.Similar toJsonNode.asString(), but instead of throwing an exception for non-coercible values or coercingnull(or missing value), will returnOptional.empty().tools.jackson.core.JsonTokenasToken()Method that can be used for efficient type detection when using stream abstraction for traversing nodes.byte[]As it is possible that some implementations embed byte[] as POJONode (despite optimal beingBinaryNode), let's add support for exposing binary data here too.booleanEquality for node objects is defined as full (deep) value equality.Return the type of this nodegetPojo()Method that can be used to access the POJO this node wraps.inthashCode()booleanfinal voidserialize(tools.jackson.core.JsonGenerator gen, SerializationContext ctxt) Method called to serialize node instances using given generator.Methods inherited from class tools.jackson.databind.node.ValueNode
_at, deepCopy, findParent, findParents, findValue, findValues, findValuesAsString, get, get, has, has, hasNonNull, hasNonNull, isEmpty, path, path, serializeWithTypeMethods inherited from class tools.jackson.databind.node.BaseJsonNode
_jsonPointerIfValid, _reportBigDecimalConversionNaNFail, _reportBigIntegerConversionFractionFail, _reportBigIntegerConversionNaNFail, _reportCoercionFail, _reportCoercionFail, _reportConversionFail, _reportDoubleConversionRangeFail, _reportFloatConversionRangeFail, _reportIntConversionFractionFail, _reportIntConversionNaNFail, _reportIntConversionRangeFail, _reportLongConversionFractionFail, _reportLongConversionNaNFail, _reportLongConversionRangeFail, _reportShortConversionFractionFail, _reportShortConversionRangeFail, _reportWrongNodeType, _withArray, _withObject, _withXxxMayReplace, _withXxxVerifyReplace, asArray, asArrayOpt, asBoolean, asObject, asObjectOpt, asString, bigIntegerValue, bigIntegerValue, bigIntegerValueOpt, booleanValue, booleanValue, booleanValueOpt, decimalValue, decimalValue, decimalValueOpt, doubleValue, doubleValue, doubleValueOpt, findPath, floatValue, floatValue, floatValueOpt, intValue, intValue, intValueOpt, isMissingNode, longValue, longValue, longValueOpt, numberType, numberValue, required, required, shortValue, shortValue, shortValueOpt, stringValue, stringValue, stringValueOpt, toPrettyString, toString, traverse, withArray, withObjectMethods inherited from class tools.jackson.databind.JsonNode
_reportRequiredViolation, _reportUnsupportedOperation, _this, asOptional, asText, asText, at, at, canConvertToExactIntegral, canConvertToInt, canConvertToLong, canConvertToShort, equals, findParents, findValues, findValuesAsString, forEachEntry, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainer, isDouble, isFloat, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isNull, isNumber, isObject, isPojo, isShort, isString, isTextual, isValueNode, iterator, map, missingAs, missingAs, nullAs, nullAs, optional, optional, properties, propertyNames, propertyStream, require, requiredAt, requiredAt, requireNonNull, size, spliterator, textValue, values, valueStream, withArray, withArray, withArray, withArrayProperty, withObject, withObject, withObject, withObjectPropertyMethods inherited from class tools.jackson.databind.JacksonSerializable.Base
isEmpty
-
Field Details
-
_value
-
-
Constructor Details
-
POJONode
-
-
Method Details
-
_valueDesc
Description copied from class:BaseJsonNodeMethod for implementation classes to return a short description of contained value, to be used in error messages.- Specified by:
_valueDescin classBaseJsonNode
-
getNodeType
Description copied from class:JsonNodeReturn the type of this node- Specified by:
getNodeTypein classJsonNode- Returns:
- the node type as a
JsonNodeTypeenum value
-
asToken
public tools.jackson.core.JsonToken asToken()Description copied from class:BaseJsonNodeMethod that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the firstJsonTokenthat equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple) -
isEmbeddedValue
public boolean isEmbeddedValue()- Specified by:
isEmbeddedValuein interfacetools.jackson.core.TreeNode- Overrides:
isEmbeddedValuein classBaseJsonNode
-
_asBoolean
Description copied from class:BaseJsonNodeMethod sub-classes should override if they can producebooleanvalues viaBaseJsonNode.asBoolean()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).- Overrides:
_asBooleanin classBaseJsonNode- Returns:
- Coerced value if possible; otherwise
nullto indicate this node cannot be coerced.
-
asBoolean
public boolean asBoolean(boolean defaultValue) Description copied from class:JsonNodeSimilar toJsonNode.asBoolean(), but instead of throwing an exception for non-coercible values or coercingnull(or missing node), will return the specified default value.- Overrides:
asBooleanin classBaseJsonNode
-
asBooleanOpt
Description copied from class:JsonNodeSimilar toJsonNode.asBoolean(), but instead of throwing an exception for non-coercible values or coercingnull(or missing node), will returnOptional.empty().- Overrides:
asBooleanOptin classBaseJsonNode
-
_asString
Description copied from class:BaseJsonNodeMethod sub-classes should override if they can produceStringvalues viaBaseJsonNode.asString()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).- Overrides:
_asStringin classBaseJsonNode- Returns:
- Coerced value if possible; otherwise
nullto indicate this node cannot be coerced.
-
asString
Description copied from class:JsonNodeSimilar toJsonNode.asString(), but instead of throwing an exception for non-coercible values or coercingnull(or missing value), will return the specified default value.- Overrides:
asStringin classBaseJsonNode
-
asStringOpt
Description copied from class:JsonNodeSimilar toJsonNode.asString(), but instead of throwing an exception for non-coercible values or coercingnull(or missing value), will returnOptional.empty().- Overrides:
asStringOptin classBaseJsonNode
-
binaryValue
public byte[] binaryValue()As it is possible that some implementations embed byte[] as POJONode (despite optimal beingBinaryNode), let's add support for exposing binary data here too.- Overrides:
binaryValuein classBaseJsonNode- Returns:
- Binary value this node represents (if node contains binary value)
-
asShort
public short asShort()Description copied from class:JsonNodeMethod similar toJsonNode.shortValue()but in addition to coercing Number values (same asJsonNode.shortValue()), will also try to coerce a couple of additional types (or cases):- JSON Floating-point numbers with fractions (ones without fractions
are ok for
JsonNode.shortValue()) will be truncated toshort(if (and only if) they fit inshortrange). - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0)) - Missing node (coerced to
0)) - POJO nodes that contain Number values
- Overrides:
asShortin classBaseJsonNode- Returns:
shortvalue this node represents, if possible to accurately represent
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asShort
public short asShort(short defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.shortValue(), but that will return specifieddefaultValueif this node cannot be converted toshortor if the value isnull.- Overrides:
asShortin classBaseJsonNode- Parameters:
defaultValue- Value to return if this node cannot be converted toshort- Returns:
shortvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
asShortOpt
Description copied from class:JsonNodeMethod similar toJsonNode.asShort(), but that will return (Optional.empty()) if this node cannot be coerced toshortor if the value isnull.- Overrides:
asShortOptin classBaseJsonNode- Returns:
Optional<Short>value this node represents, if possible to accurately represent;Optional.empty()otherwise
-
asInt
public int asInt()Description copied from class:JsonNodeMethod similar toJsonNode.intValue()but in addition to coercing Number values (same asJsonNode.intValue()), will also try to coerce a couple of additional types (or cases):- JSON Floating-point numbers with fractions (ones without fractions
are ok for
JsonNode.intValue()) will be truncated toint(if (and only if) they fit inintrange). - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0)) - Missing node (coerced to
0)) - POJO nodes that contain Number values
- Overrides:
asIntin classBaseJsonNode- Returns:
intvalue this node represents, if possible to accurately represent
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asInt
public int asInt(int defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.intValue(), but that will return specifieddefaultValueif this node cannot be converted tointor if the value isnull.- Overrides:
asIntin classBaseJsonNode- Parameters:
defaultValue- Value to return if this node cannot be converted toint- Returns:
intvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
asIntOpt
Description copied from class:JsonNodeMethod similar toJsonNode.asInt(), but that will return (OptionalInt.empty()) if this node cannot be coerced tointor if the value isnull.- Overrides:
asIntOptin classBaseJsonNode- Returns:
OptionalIntvalue this node represents, if possible to accurately represent;OptionalInt.empty()otherwise
-
asLong
public long asLong()Description copied from class:JsonNodeMethod similar toJsonNode.longValue()but in addition to coercing Number values (same asJsonNode.longValue()), will also try to coerce a couple of additional types (or cases):- JSON Floating-point numbers with fractions (ones without fractions
are ok for
JsonNode.longValue()) will be truncated tolong(if (and only if) they fit inlongrange). - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0)) - Missing node (coerced to
0)) - POJO nodes that contain Number values
- Overrides:
asLongin classBaseJsonNode- Returns:
longvalue this node represents, if possible to accurately represent
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asLong
public long asLong(long defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.asLong(), but that will return specifieddefaultValueif this node cannot be coerced tolong(instead of throwing an exception) or if the value isnull.- Overrides:
asLongin classBaseJsonNode- Parameters:
defaultValue- Value to return if this node cannot be coerced tolong- Returns:
longvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
asLongOpt
Description copied from class:JsonNodeMethod similar toJsonNode.asLong(), but that will return (OptionalLong.empty()) if this node cannot be coerced tolongor if the value isnull.- Overrides:
asLongOptin classBaseJsonNode- Returns:
OptionalLongvalue this node represents (or can be coerced to),OptionalLong.empty()otherwise
-
asBigInteger
Description copied from class:JsonNodeMethod similar toJsonNode.bigIntegerValue()but in addition to coercing Number values (same asJsonNode.bigIntegerValue()), will also try to coerce a couple of additional types (or cases):- JSON Floating-point numbers with fractions (ones without fractions
are ok for
JsonNode.bigIntegerValue()) will be truncated to integer value (like withBigDecimal.toBigInteger())) - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
BigInteger.ZERO)) - Missing node (coerced to
BigInteger.ZERO)) - POJO nodes that contain Number values
- Overrides:
asBigIntegerin classBaseJsonNode- Returns:
BigIntegervalue this node represents, if possible to accurately convert;defaultValueotherwise
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asBigInteger
Description copied from class:JsonNodeMethod similar toJsonNode.asBigInteger(), but that will return specifieddefaultValueif this node cannot be converted toBigIntegeror if the value isnull.- Overrides:
asBigIntegerin classBaseJsonNode- Parameters:
defaultValue- Value to return if this node cannot be converted toBigInteger- Returns:
BigIntegervalue this node represents, if possible to accurately convert;defaultValueotherwise
-
asBigIntegerOpt
Description copied from class:JsonNodeMethod similar toJsonNode.bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to JavaBigIntegeror if the value isnull.- Overrides:
asBigIntegerOptin classBaseJsonNode- Returns:
BigIntegervalue this node represents, asOptional<BigInteger>, if possible to accurately represent;Optional.empty()otherwise.
-
asFloat
public float asFloat()Description copied from class:JsonNodeMethod similar toJsonNode.floatValue()but in addition to coercing Number values will also try coerce couple of additional types:- JSON String that represents JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0.0f)) - Missing node (coerced to
0.0f)) - POJO nodes that contain Number values
- Overrides:
asFloatin classBaseJsonNode- Returns:
floatvalue this node represents, if possible to accurately represent
-
asFloat
public float asFloat(float defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.asFloat(), but that will returndefaultValueif this node cannot be coerced tofloator if the value isnull.- Overrides:
asFloatin classBaseJsonNode- Returns:
floatvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
asFloatOpt
Description copied from class:JsonNodeMethod similar toJsonNode.asFloat(), but that will return (Optional.empty()) if this node cannot be coerced tofloator if the value isnull.- Overrides:
asFloatOptin classBaseJsonNode- Returns:
Optional<Float>value this node represents, if possible to accurately represent;Optional.empty()otherwise
-
asDouble
public double asDouble()Description copied from class:JsonNodeMethod similar toJsonNode.doubleValue()but in addition to coercing Number values will also try coerce couple of additional types:- JSON String that represents JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
0.0d)) - Missing node (coerced to
0.0d)) - POJO nodes that contain Number values
- Overrides:
asDoublein classBaseJsonNode- Returns:
doublevalue this node represents, if possible to accurately represent
-
asDouble
public double asDouble(double defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.asDouble(), but that will returndefaultValueif this node cannot be coerced todoubleor if the value isnull.- Overrides:
asDoublein classBaseJsonNode- Returns:
doublevalue this node represents, if possible to accurately represent;defaultValueotherwise
-
asDoubleOpt
Description copied from class:JsonNodeMethod similar toJsonNode.asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced todoubleor if the value isnull.- Overrides:
asDoubleOptin classBaseJsonNode- Returns:
OptionalDoublevalue this node represents, if possible to accurately represent;OptionalDouble.empty()otherwise
-
asDecimal
Description copied from class:JsonNodeMethod that will try to access value of this node as aBigDecimal: but if node value cannot be expressed exactly as aBigDecimal, aJsonNodeExceptionwill be thrown. Access works for following cases:- JSON Floating-point values (but not "NaN" or "Infinity")
- JSON Integer values
- JSON String that represents JSON Numbers ("stringified" numbers)
- JSON Null (coerced to
BigDecimal.ZERO)) - Missing node (coerced to
BigDecimal.ZERO)) - POJO nodes that contain Number values
- Overrides:
asDecimalin classBaseJsonNode- Returns:
BigDecimalvalue this node represents, if possible to accurately represent
-
asDecimal
Description copied from class:JsonNodeMethod similar toJsonNode.asDecimal(), but that will returndefaultValueif this node cannot be coerced to JavaBigDecimalor if the value isnull.- Overrides:
asDecimalin classBaseJsonNode- Returns:
BigDecimalvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
asDecimalOpt
Description copied from class:JsonNodeMethod similar toJsonNode.asDecimal(), but that will return emptyOptional(Optional.empty()) if this node cannot be coerced toBigDecimalor if the value isnull.- Overrides:
asDecimalOptin classBaseJsonNode- Returns:
- Java
BigDecimalvalue this node represents, asOptional<BigDecimal>, if possible to accurately represent;Optional.empty()otherwise
-
_extractAsLong
-
_extractAsBigInteger
-
_extractAsFloat
-
_extractAsDouble
-
_extractAsBigDecimal
-
serialize
public final void serialize(tools.jackson.core.JsonGenerator gen, SerializationContext ctxt) throws tools.jackson.core.JacksonException Description copied from class:BaseJsonNodeMethod called to serialize node instances using given generator.- Specified by:
serializein interfaceJacksonSerializable- Specified by:
serializein classBaseJsonNode- Throws:
tools.jackson.core.JacksonException
-
getPojo
Method that can be used to access the POJO this node wraps. -
equals
Description copied from class:JsonNodeEquality for node objects is defined as full (deep) value equality. This means that it is possible to compare complete JSON trees for equality by comparing equality of root nodes.Note: marked as abstract to ensure all implementation classes define it properly and not rely on definition from
Object. -
_pojoEquals
-
hashCode
public int hashCode()- Specified by:
hashCodein classBaseJsonNode
-