- All Implemented Interfaces:
Serializable,Iterable<JsonNode>,TreeNode,JacksonSerializable
- Direct Known Subclasses:
BigIntegerNode,IntNode,LongNode,ShortNode
Intermediate node class used for numeric nodes that contain
integral values: provides partial implementation of common
methods.
- 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
Fields 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 abstract doubleprotected abstract floatMethod 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 (converted to0)) POJO nodes that contain Number valuesasBigInteger(BigInteger defaultValue) Method similar toJsonNode.asBigInteger(), but that will return specifieddefaultValueif this node cannot be converted toBigInteger.Method similar toJsonNode.bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to JavaBigInteger.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 JavaBigDecimal.Method similar toJsonNode.asDecimal(), but that will return emptyOptional(Optional.empty()) if this node cannot be coerced toBigDecimal.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 (converted to0.0d) POJO nodes that contain Number valuesdoubleasDouble(double defaultValue) Method similar toJsonNode.asDouble(), but that will returndefaultValueif this node cannot be coerced todouble.Method similar toJsonNode.asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced todouble.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 (converted to0.0f) POJO nodes that contain Number valuesfloatasFloat(float defaultValue) Method similar toJsonNode.asFloat(), but that will returndefaultValueif this node cannot be coerced tofloat.Method similar toJsonNode.asFloat(), but that will return (Optional.empty()) if this node cannot be coerced tofloat.final JsonTokenasToken()Method that can be used for efficient type detection when using stream abstraction for traversing nodes.abstract BigIntegerMethod that will try to access value of this node as aBigInteger, but if node value cannot be expressed exactly as aBigInteger, aJsonNodeExceptionwill be thrown.bigIntegerValue(BigInteger defaultValue) Method similar toJsonNode.bigIntegerValue(), but that will return specifieddefaultValueif this node cannot be converted to JavaBigInteger.Method similar toJsonNode.bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to JavaBigInteger.final booleanMethod that can be used to check whether this node is a numeric node (JsonNode.isNumber()would return true) AND can be converted without loss toint(that is, its value fits in Java's 32-bit signed integer type,intand if it is a floating-point number, it does not have fractional part).final booleanMethod that can be used to check whether this node is a numeric node (JsonNode.isNumber()would return true) AND can be converted without loss tolong(that is, its value fits in Java's 64-bit signed integer type,longand if it is a floating-point number, it does not have fractional part).final booleanMethod that can be used to check whether this node is a numeric node (JsonNode.isNumber()would return true) AND can be converted without loss toshort(that is, its value fits in Java's 16-bit signed integer type,shortand if it is a floating-point number, it does not have fractional part).decimalValue(BigDecimal defaultValue) Method similar toJsonNode.decimalValue(), but that will returndefaultValueif this node cannot be coerced to JavaBigDecimal.Method similar toJsonNode.decimalValue(), but that will return emptyOptional(Optional.empty()) if this node cannot be coerced toBigDecimal.doubleMethod that will try to access value of this node as adouble: but if node value cannot be expressed exactly as adouble, aJsonNodeExceptionwill be thrown.doubledoubleValue(double defaultValue) Method similar toJsonNode.doubleValue(), but that will return specifieddefaultValueif this node cannot be converted todouble.Method similar toJsonNode.doubleValue(), but that will return emptyOptionalLong(OptionalDouble.empty()) if this node cannot be converted to Javadouble.floatMethod that will try to access value of this node as a Javafloat: but if node value cannot be expressed exactly as afloat, aJsonNodeExceptionwill be thrown.floatfloatValue(float defaultValue) Method similar toJsonNode.floatValue(), but that will return specifieddefaultValueif this node cannot be converted tofloat.Method similar toJsonNode.floatValue(), but that will return emptyOptional<Float>(Optional.empty()) if this node cannot be converted to Javafloat.booleanConvenience method for checking whether this node is aNumericFPNodethat contains non-zero fractional part (as opposed to only integer part).final booleanfinal booleanisNaN()Convenience method for checking whether this node is aFloatNodeorDoubleNodethat contains "not-a-number" (NaN) value.Methods inherited from class tools.jackson.databind.node.NumericNode
_asIntValueUnchecked, _asLongValueUnchecked, _asShortValueUnchecked, _asString, _valueDesc, asInt, asInt, asIntOpt, asLong, asLong, asLongOpt, asShort, asShort, asShortOpt, decimalValue, deepCopy, getNodeType, inIntRange, inLongRange, inShortRange, intValue, intValue, intValueOpt, longValue, longValue, longValueOpt, numberType, numberValue, shortValue, shortValue, shortValueOptMethods inherited from class tools.jackson.databind.node.ValueNode
_at, findParent, findParents, findValue, findValues, findValuesAsString, get, get, has, has, hasNonNull, hasNonNull, isEmpty, path, path, serializeWithTypeMethods inherited from class tools.jackson.databind.node.BaseJsonNode
_asBoolean, _jsonPointerIfValid, _reportBigDecimalCoercionNaNFail, _reportBigIntegerCoercionFractionFail, _reportBigIntegerCoercionNaNFail, _reportCoercionFail, _reportDoubleCoercionRangeFail, _reportFloatCoercionRangeFail, _reportIntCoercionFractionFail, _reportIntCoercionNaNFail, _reportIntCoercionRangeFail, _reportLongCoercionFractionFail, _reportLongCoercionNaNFail, _reportLongCoercionRangeFail, _reportShortCoercionFractionFail, _reportShortCoercionRangeFail, _reportWrongNodeType, _withArray, _withObject, _withXxxMayReplace, _withXxxVerifyReplace, asBoolean, asBoolean, asBooleanOpt, asString, asString, asStringOpt, binaryValue, booleanValue, booleanValue, booleanValueOpt, findPath, hashCode, isEmbeddedValue, isMissingNode, required, required, serialize, stringValue, stringValue, stringValueOpt, toPrettyString, toString, traverse, withArray, withObjectMethods inherited from class tools.jackson.databind.JsonNode
_reportRequiredViolation, _reportUnsupportedOperation, _this, asOptional, asText, asText, at, at, canConvertToExactIntegral, equals, equals, findParents, findValues, findValuesAsString, forEachEntry, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainer, isDouble, isFloat, isFloatingPointNumber, isInt, isLong, isNull, isNumber, isObject, isPojo, isShort, isString, isTextual, isValueNode, iterator, 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
-
Constructor Details
-
NumericIntNode
public NumericIntNode()
-
-
Method Details
-
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) -
isIntegralNumber
public final boolean isIntegralNumber()- Overrides:
isIntegralNumberin classJsonNode- Returns:
- True if this node represents an integral (integer) numeric JSON value
-
isNaN
public final boolean isNaN()Description copied from class:NumericNodeConvenience method for checking whether this node is aFloatNodeorDoubleNodethat contains "not-a-number" (NaN) value.- Specified by:
isNaNin classNumericNode
-
canConvertToShort
public final boolean canConvertToShort()Description copied from class:JsonNodeMethod that can be used to check whether this node is a numeric node (JsonNode.isNumber()would return true) AND can be converted without loss toshort(that is, its value fits in Java's 16-bit signed integer type,shortand if it is a floating-point number, it does not have fractional part).NOTE: this method does not consider possible value type conversion from non-number types like JSON String into Number; so even if this method returns false, it is possible that
JsonNode.asShort()could still succeed.- Specified by:
canConvertToShortin classNumericNode
-
canConvertToInt
public final boolean canConvertToInt()Description copied from class:JsonNodeMethod that can be used to check whether this node is a numeric node (JsonNode.isNumber()would return true) AND can be converted without loss toint(that is, its value fits in Java's 32-bit signed integer type,intand if it is a floating-point number, it does not have fractional part).NOTE: this method does not consider possible value type conversion from non-number types like JSON String into Number; so even if this method returns false, it is possible that
JsonNode.asInt()could still succeed.- Specified by:
canConvertToIntin classNumericNode
-
canConvertToLong
public final boolean canConvertToLong()Description copied from class:JsonNodeMethod that can be used to check whether this node is a numeric node (JsonNode.isNumber()would return true) AND can be converted without loss tolong(that is, its value fits in Java's 64-bit signed integer type,longand if it is a floating-point number, it does not have fractional part).NOTE: this method does not consider possible value type conversion from non-number types like JSON String into Number; so even if this method returns false, it is possible that
JsonNode.asLong()could still succeed.- Specified by:
canConvertToLongin classNumericNode
-
bigIntegerValue
Description copied from class:JsonNodeMethod that will try to access value of this node as aBigInteger, but if node value cannot be expressed exactly as aBigInteger, aJsonNodeExceptionwill be thrown. Access works for following cases:- JSON Integer values
- JSON Floating-point values that do not have fractional part.
- Specified by:
bigIntegerValuein classNumericNode- Returns:
BigIntegervalue this node represents, if possible to accurately represent
-
bigIntegerValue
Description copied from class:JsonNodeMethod similar toJsonNode.bigIntegerValue(), but that will return specifieddefaultValueif this node cannot be converted to JavaBigInteger.- Specified by:
bigIntegerValuein classNumericNode- Parameters:
defaultValue- Value to return if this node cannot be converted to JavaBigInteger- Returns:
- Java
BigIntegervalue this node represents, if possible to accurately represent;defaultValueotherwise
-
bigIntegerValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to JavaBigInteger.- Specified by:
bigIntegerValueOptin classNumericNode- Returns:
- Java
BigIntegervalue this node represents, asOptional<BigInteger>, if possible to accurately represent;Optional.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 (converted to
0)) - POJO nodes that contain Number values
- Specified by:
asBigIntegerin classNumericNode- 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 toBigInteger.- Specified by:
asBigIntegerin classNumericNode- 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 JavaBigInteger.- Specified by:
asBigIntegerOptin classNumericNode- Returns:
BigIntegervalue this node represents, asOptional<BigInteger>, if possible to accurately represent;Optional.empty()otherwise.
-
floatValue
public float floatValue()Description copied from class:JsonNodeMethod that will try to access value of this node as a Javafloat: but if node value cannot be expressed exactly as afloat, aJsonNodeExceptionwill be thrown. Access works for following cases:- JSON Floating-point values that fit in Java 32-bit
doublerange - JSON Integer values that fit in Java 32-bit
doublerange
- Specified by:
floatValuein classNumericNode- Returns:
Floatvalue this node represents, if possible to accurately represent
- JSON Floating-point values that fit in Java 32-bit
-
floatValue
public float floatValue(float defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.floatValue(), but that will return specifieddefaultValueif this node cannot be converted tofloat.- Specified by:
floatValuein classNumericNode- Parameters:
defaultValue- Value to return if this node cannot be converted tofloat- Returns:
floatvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
floatValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.floatValue(), but that will return emptyOptional<Float>(Optional.empty()) if this node cannot be converted to Javafloat.- Specified by:
floatValueOptin classNumericNode- Returns:
- Java
floatvalue this node represents, asOptional<Float>, 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 (converted to
0.0f) - POJO nodes that contain Number values
- Specified by:
asFloatin classNumericNode- 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 tofloat.- Specified by:
asFloatin classNumericNode- 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 tofloat.- Specified by:
asFloatOptin classNumericNode- Returns:
Optional<Float>value this node represents, if possible to accurately represent;Optional.empty()otherwise
-
doubleValue
public double doubleValue()Description copied from class:JsonNodeMethod that will try to access value of this node as adouble: but if node value cannot be expressed exactly as adouble, aJsonNodeExceptionwill be thrown. Access works for following cases:- JSON Floating-point values that fit in Java 64-bit
doublerange - JSON Integer values that fit in Java 64-bit
doublerange
NOTE: for more lenient conversions, use
JsonNode.asDouble()- Specified by:
doubleValuein classNumericNode- Returns:
Doublevalue this node represents, if possible to accurately represent
- JSON Floating-point values that fit in Java 64-bit
-
doubleValue
public double doubleValue(double defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.doubleValue(), but that will return specifieddefaultValueif this node cannot be converted todouble.- Specified by:
doubleValuein classNumericNode- Parameters:
defaultValue- Value to return if this node cannot be converted todouble- Returns:
doublevalue this node represents, if possible to accurately represent;defaultValueotherwise
-
doubleValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.doubleValue(), but that will return emptyOptionalLong(OptionalDouble.empty()) if this node cannot be converted to Javadouble.- Specified by:
doubleValueOptin classNumericNode- Returns:
- Java
doublevalue this node represents, asOptionalDouble, if possible to accurately represent;OptionalDouble.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 (converted to
0.0d) - POJO nodes that contain Number values
- Specified by:
asDoublein classNumericNode- 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 todouble.- Specified by:
asDoublein classNumericNode- 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 todouble.- Specified by:
asDoubleOptin classNumericNode- Returns:
OptionalDoublevalue this node represents, if possible to accurately represent;OptionalDouble.empty()otherwise
-
decimalValue
Description copied from class:JsonNodeMethod similar toJsonNode.decimalValue(), but that will returndefaultValueif this node cannot be coerced to JavaBigDecimal.- Specified by:
decimalValuein classNumericNode- Returns:
BigDecimalvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
decimalValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.decimalValue(), but that will return emptyOptional(Optional.empty()) if this node cannot be coerced toBigDecimal.- Specified by:
decimalValueOptin classNumericNode- Returns:
- Java
BigDecimalvalue this node represents, asOptional<BigDecimal>, if possible to accurately represent;Optional.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 (converted to
BigDecimal.ZERO)) - POJO nodes that contain Number values
- Specified by:
asDecimalin classNumericNode- 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 JavaBigDecimal.- Specified by:
asDecimalin classNumericNode- 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 toBigDecimal.- Specified by:
asDecimalOptin classNumericNode- Returns:
- Java
BigDecimalvalue this node represents, asOptional<BigDecimal>, if possible to accurately represent;Optional.empty()otherwise
-
hasFractionalPart
public boolean hasFractionalPart()Description copied from class:NumericNodeConvenience method for checking whether this node is aNumericFPNodethat contains non-zero fractional part (as opposed to only integer part). Always returns false for integralNumericNodes (that is, s).- Specified by:
hasFractionalPartin classNumericNode
-
_asFloatValueUnchecked
protected abstract float _asFloatValueUnchecked() -
_asDoubleValueUnchecked
protected abstract double _asDoubleValueUnchecked()
-