- 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.OverwriteMode
Nested 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, MISSING
Fields inherited from class tools.jackson.databind.node.BaseJsonNode
OPT_FALSE, OPT_TRUE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract double
protected abstract float
protected abstract int
protected abstract boolean
protected abstract boolean
protected abstract boolean
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 (converted to0
)) POJO nodes that contain Number valuesasBigInteger
(BigInteger defaultValue) Method similar toJsonNode.asBigInteger()
, but that will return specifieddefaultValue
if 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
, aJsonNodeException
will be thrown.asDecimal
(BigDecimal defaultValue) Method similar toJsonNode.asDecimal()
, but that will returndefaultValue
if 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
.double
asDouble()
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 valuesdouble
asDouble
(double defaultValue) Method similar toJsonNode.asDouble()
, but that will returndefaultValue
if this node cannot be coerced todouble
.Method similar toJsonNode.asDouble()
, but that will return (OptionalDouble.empty()
) if this node cannot be coerced todouble
.float
asFloat()
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 valuesfloat
asFloat
(float defaultValue) Method similar toJsonNode.asFloat()
, but that will returndefaultValue
if this node cannot be coerced tofloat
.Method similar toJsonNode.asFloat()
, but that will return (Optional.empty()
) if this node cannot be coerced tofloat
.final JsonToken
asToken()
Method that can be used for efficient type detection when using stream abstraction for traversing nodes.abstract BigInteger
Method that will try to access value of this node as aBigInteger
, but if node value cannot be expressed exactly as aBigInteger
, aJsonNodeException
will be thrown.bigIntegerValue
(BigInteger defaultValue) Method similar toJsonNode.bigIntegerValue()
, but that will return specifieddefaultValue
if 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 boolean
Method 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,int
and if it is a floating-point number, it does not have fractional part).final boolean
Method 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,long
and if it is a floating-point number, it does not have fractional part).final boolean
Method 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,short
and if it is a floating-point number, it does not have fractional part).decimalValue
(BigDecimal defaultValue) Method similar toJsonNode.decimalValue()
, but that will returndefaultValue
if 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
.double
Method that will try to access value of this node as adouble
: but if node value cannot be expressed exactly as adouble
, aJsonNodeException
will be thrown.double
doubleValue
(double defaultValue) Method similar toJsonNode.doubleValue()
, but that will return specifieddefaultValue
if 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
.float
Method that will try to access value of this node as a Javafloat
: but if node value cannot be expressed exactly as afloat
, aJsonNodeException
will be thrown.float
floatValue
(float defaultValue) Method similar toJsonNode.floatValue()
, but that will return specifieddefaultValue
if 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
.final boolean
final boolean
isNaN()
Convenience method for checking whether this node is aFloatNode
orDoubleNode
that contains "not-a-number" (NaN) value.Methods inherited from class tools.jackson.databind.node.NumericNode
_asString, _valueDesc, asInt, asInt, asIntOpt, asLong, asLong, asLongOpt, asShort, asShort, asShortOpt, decimalValue, deepCopy, getNodeType, intValue, intValue, intValueOpt, longValue, longValue, longValueOpt, numberType, numberValue, shortValue, shortValue, shortValueOpt
Methods inherited from class tools.jackson.databind.node.ValueNode
_at, findParent, findParents, findValue, findValues, findValuesAsString, get, get, has, has, hasNonNull, hasNonNull, isEmpty, path, path, serializeWithType
Methods 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, withObject
Methods 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, withObjectProperty
Methods inherited from class tools.jackson.databind.JacksonSerializable.Base
isEmpty
-
Constructor Details
-
NumericIntNode
public NumericIntNode()
-
-
Method Details
-
asToken
Description copied from class:BaseJsonNode
Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the firstJsonToken
that 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:
isIntegralNumber
in classJsonNode
- Returns:
- True if this node represents an integral (integer) numeric JSON value
-
isNaN
public final boolean isNaN()Description copied from class:NumericNode
Convenience method for checking whether this node is aFloatNode
orDoubleNode
that contains "not-a-number" (NaN) value.- Specified by:
isNaN
in classNumericNode
-
canConvertToShort
public final boolean canConvertToShort()Description copied from class:JsonNode
Method 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,short
and 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:
canConvertToShort
in classNumericNode
-
canConvertToInt
public final boolean canConvertToInt()Description copied from class:JsonNode
Method 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,int
and 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:
canConvertToInt
in classNumericNode
-
canConvertToLong
public final boolean canConvertToLong()Description copied from class:JsonNode
Method 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,long
and 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:
canConvertToLong
in classNumericNode
-
bigIntegerValue
Description copied from class:JsonNode
Method that will try to access value of this node as aBigInteger
, but if node value cannot be expressed exactly as aBigInteger
, aJsonNodeException
will be thrown. Access works for following cases:- JSON Integer values
- JSON Floating-point values that do not have fractional part.
- Specified by:
bigIntegerValue
in classNumericNode
- Returns:
BigInteger
value this node represents, if possible to accurately represent
-
bigIntegerValue
Description copied from class:JsonNode
Method similar toJsonNode.bigIntegerValue()
, but that will return specifieddefaultValue
if this node cannot be converted to JavaBigInteger
.- Specified by:
bigIntegerValue
in classNumericNode
- Parameters:
defaultValue
- Value to return if this node cannot be converted to JavaBigInteger
- Returns:
- Java
BigInteger
value this node represents, if possible to accurately represent;defaultValue
otherwise
-
bigIntegerValueOpt
Description copied from class:JsonNode
Method similar toJsonNode.bigIntegerValue()
, but that will return empty (Optional.empty()
) if this node cannot be converted to JavaBigInteger
.- Specified by:
bigIntegerValueOpt
in classNumericNode
- Returns:
- Java
BigInteger
value this node represents, asOptional<BigInteger>
, if possible to accurately represent;Optional.empty()
otherwise
-
asBigInteger
Description copied from class:JsonNode
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 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:
asBigInteger
in classNumericNode
- Returns:
BigInteger
value this node represents, if possible to accurately convert;defaultValue
otherwise
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asBigInteger
Description copied from class:JsonNode
Method similar toJsonNode.asBigInteger()
, but that will return specifieddefaultValue
if this node cannot be converted toBigInteger
.- Specified by:
asBigInteger
in classNumericNode
- Parameters:
defaultValue
- Value to return if this node cannot be converted toBigInteger
- Returns:
BigInteger
value this node represents, if possible to accurately convert;defaultValue
otherwise
-
asBigIntegerOpt
Description copied from class:JsonNode
Method similar toJsonNode.bigIntegerValue()
, but that will return empty (Optional.empty()
) if this node cannot be converted to JavaBigInteger
.- Specified by:
asBigIntegerOpt
in classNumericNode
- Returns:
BigInteger
value this node represents, asOptional<BigInteger>
, if possible to accurately represent;Optional.empty()
otherwise.
-
floatValue
public float floatValue()Description copied from class:JsonNode
Method that will try to access value of this node as a Javafloat
: but if node value cannot be expressed exactly as afloat
, aJsonNodeException
will be thrown. Access works for following cases:- JSON Floating-point values that fit in Java 32-bit
double
range - JSON Integer values that fit in Java 32-bit
double
range
- Specified by:
floatValue
in classNumericNode
- Returns:
Float
value 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:JsonNode
Method similar toJsonNode.floatValue()
, but that will return specifieddefaultValue
if this node cannot be converted tofloat
.- Specified by:
floatValue
in classNumericNode
- Parameters:
defaultValue
- Value to return if this node cannot be converted tofloat
- Returns:
float
value this node represents, if possible to accurately represent;defaultValue
otherwise
-
floatValueOpt
Description copied from class:JsonNode
Method similar toJsonNode.floatValue()
, but that will return emptyOptional<Float>
(Optional.empty()
) if this node cannot be converted to Javafloat
.- Specified by:
floatValueOpt
in classNumericNode
- Returns:
- Java
float
value this node represents, asOptional<Float>
, if possible to accurately represent;Optional.empty()
otherwise
-
asFloat
public float asFloat()Description copied from class:JsonNode
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 to
0.0f
) - POJO nodes that contain Number values
- Specified by:
asFloat
in classNumericNode
- Returns:
float
value this node represents, if possible to accurately represent
-
asFloat
public float asFloat(float defaultValue) Description copied from class:JsonNode
Method similar toJsonNode.asFloat()
, but that will returndefaultValue
if this node cannot be coerced tofloat
.- Specified by:
asFloat
in classNumericNode
- Returns:
float
value this node represents, if possible to accurately represent;defaultValue
otherwise
-
asFloatOpt
Description copied from class:JsonNode
Method similar toJsonNode.asFloat()
, but that will return (Optional.empty()
) if this node cannot be coerced tofloat
.- Specified by:
asFloatOpt
in classNumericNode
- Returns:
Optional<Float>
value this node represents, if possible to accurately represent;Optional.empty()
otherwise
-
doubleValue
public double doubleValue()Description copied from class:JsonNode
Method that will try to access value of this node as adouble
: but if node value cannot be expressed exactly as adouble
, aJsonNodeException
will be thrown. Access works for following cases:- JSON Floating-point values that fit in Java 64-bit
double
range - JSON Integer values that fit in Java 64-bit
double
range
NOTE: for more lenient conversions, use
JsonNode.asDouble()
- Specified by:
doubleValue
in classNumericNode
- Returns:
Double
value 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:JsonNode
Method similar toJsonNode.doubleValue()
, but that will return specifieddefaultValue
if this node cannot be converted todouble
.- Specified by:
doubleValue
in classNumericNode
- Parameters:
defaultValue
- Value to return if this node cannot be converted todouble
- Returns:
double
value this node represents, if possible to accurately represent;defaultValue
otherwise
-
doubleValueOpt
Description copied from class:JsonNode
Method similar toJsonNode.doubleValue()
, but that will return emptyOptionalLong
(OptionalDouble.empty()
) if this node cannot be converted to Javadouble
.- Specified by:
doubleValueOpt
in classNumericNode
- Returns:
- Java
double
value this node represents, asOptionalDouble
, if possible to accurately represent;OptionalDouble.empty()
otherwise
-
asDouble
public double asDouble()Description copied from class:JsonNode
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 to
0.0d
) - POJO nodes that contain Number values
- Specified by:
asDouble
in classNumericNode
- Returns:
double
value this node represents, if possible to accurately represent
-
asDouble
public double asDouble(double defaultValue) Description copied from class:JsonNode
Method similar toJsonNode.asDouble()
, but that will returndefaultValue
if this node cannot be coerced todouble
.- Specified by:
asDouble
in classNumericNode
- Returns:
double
value this node represents, if possible to accurately represent;defaultValue
otherwise
-
asDoubleOpt
Description copied from class:JsonNode
Method similar toJsonNode.asDouble()
, but that will return (OptionalDouble.empty()
) if this node cannot be coerced todouble
.- Specified by:
asDoubleOpt
in classNumericNode
- Returns:
OptionalDouble
value this node represents, if possible to accurately represent;OptionalDouble.empty()
otherwise
-
decimalValue
Description copied from class:JsonNode
Method similar toJsonNode.decimalValue()
, but that will returndefaultValue
if this node cannot be coerced to JavaBigDecimal
.- Specified by:
decimalValue
in classNumericNode
- Returns:
BigDecimal
value this node represents, if possible to accurately represent;defaultValue
otherwise
-
decimalValueOpt
Description copied from class:JsonNode
Method similar toJsonNode.decimalValue()
, but that will return emptyOptional
(Optional.empty()
) if this node cannot be coerced toBigDecimal
.- Specified by:
decimalValueOpt
in classNumericNode
- Returns:
- Java
BigDecimal
value this node represents, asOptional<BigDecimal>
, if possible to accurately represent;Optional.empty()
otherwise
-
asDecimal
Description copied from class:JsonNode
Method that will try to access value of this node as aBigDecimal
: but if node value cannot be expressed exactly as aBigDecimal
, aJsonNodeException
will 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:
asDecimal
in classNumericNode
- Returns:
BigDecimal
value this node represents, if possible to accurately represent
-
asDecimal
Description copied from class:JsonNode
Method similar toJsonNode.asDecimal()
, but that will returndefaultValue
if this node cannot be coerced to JavaBigDecimal
.- Specified by:
asDecimal
in classNumericNode
- Returns:
BigDecimal
value this node represents, if possible to accurately represent;defaultValue
otherwise
-
asDecimalOpt
Description copied from class:JsonNode
Method similar toJsonNode.asDecimal()
, but that will return emptyOptional
(Optional.empty()
) if this node cannot be coerced toBigDecimal
.- Specified by:
asDecimalOpt
in classNumericNode
- Returns:
- Java
BigDecimal
value this node represents, asOptional<BigDecimal>
, if possible to accurately represent;Optional.empty()
otherwise
-
_asIntValueUnchecked
protected abstract int _asIntValueUnchecked() -
_asFloatValueUnchecked
protected abstract float _asFloatValueUnchecked() -
_asDoubleValueUnchecked
protected abstract double _asDoubleValueUnchecked() -
_inShortRange
protected abstract boolean _inShortRange() -
_inIntRange
protected abstract boolean _inIntRange() -
_inLongRange
protected abstract boolean _inLongRange()
-