- All Implemented Interfaces:
Serializable
,Iterable<JsonNode>
,TreeNode
,JacksonSerializable
Numeric node that contains values that do not fit in simple
floating point (double) values.
- 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
FieldsFields inherited from class tools.jackson.databind.node.BaseJsonNode
OPT_FALSE, OPT_TRUE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected BigInteger
Method for sub-classes to implement; returns the underlying value as aBigInteger
without any checks (wrt NaN), so caller must ensure validity prior to callingprotected BigDecimal
Method for sub-classes to implement; returns the underlying value as aBigDecimal
without any checks (wrt NaN), so caller must ensure validity prior to callingprotected int
Method for sub-classes to implement; returns the underlying value as aint
without any checks (wrt NaN or value range), so caller must ensure validity prior to callingprotected long
Method for sub-classes to implement; returns the underlying value as along
without any checks (wrt NaN or value range), so caller must ensure validity prior to callingprotected short
Method for sub-classes to implement; returns the underlying value as ashort
without any checks (wrt NaN or value range), so caller must ensure validity prior to callingMethod sub-classes should override if they can produceString
values viaBaseJsonNode.asString()
-- if not, returnnull
(in which case appropriate error will be thrown or default value returned).protected boolean
protected boolean
protected boolean
protected boolean
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
.Method that will try to access value of this node as a JavaBigDecimal
: but if node value cannot be expressed exactly as aBigDecimal
, aJsonNodeException
will be thrown.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
.boolean
Equality for node objects is defined as full (deep) value equality.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.int
hashCode()
boolean
boolean
isNaN()
Convenience method for checking whether this node is aFloatNode
orDoubleNode
that contains "not-a-number" (NaN) value.Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.Method that will try to access value of this node asNumber
that accurately represents its value, if (and only if) this is a number node (returnstrue
forJsonNode.isNumber()
).final void
serialize
(JsonGenerator g, SerializationContext provider) Method called to serialize node instances using given generator.static DecimalNode
Methods inherited from class tools.jackson.databind.node.NumericFPNode
asBigInteger, asBigInteger, asBigIntegerOpt, asInt, asInt, asIntOpt, asLong, asLong, asLongOpt, asToken, bigIntegerValue, bigIntegerValue, bigIntegerValueOpt, canConvertToExactIntegral, canConvertToInt, canConvertToLong, intValue, intValue, intValueOpt, isFloatingPointNumber, longValue, longValue, longValueOpt, shortValue
Methods inherited from class tools.jackson.databind.node.NumericNode
_valueDesc, deepCopy, getNodeType
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, isEmbeddedValue, isMissingNode, required, required, stringValue, stringValue, stringValueOpt, toPrettyString, toString, traverse, withArray, withObject
Methods inherited from class tools.jackson.databind.JsonNode
_reportRequiredViolation, _reportUnsupportedOperation, _this, asOptional, asText, asText, at, at, equals, findParents, findValues, findValuesAsString, forEachEntry, isArray, isBigInteger, isBinary, isBoolean, isContainer, isDouble, isFloat, isInt, isIntegralNumber, 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
-
Field Details
-
ZERO
-
_value
-
-
Constructor Details
-
DecimalNode
-
-
Method Details
-
valueOf
-
numberType
Description copied from class:BaseJsonNode
Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.- Specified by:
numberType
in interfaceTreeNode
- Specified by:
numberType
in classNumericNode
-
isBigDecimal
public boolean isBigDecimal()- Overrides:
isBigDecimal
in classJsonNode
-
isNaN
public 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
-
_asString
Description copied from class:BaseJsonNode
Method sub-classes should override if they can produceString
values viaBaseJsonNode.asString()
-- if not, returnnull
(in which case appropriate error will be thrown or default value returned).- Specified by:
_asString
in classNumericNode
- Returns:
- Coerced value if possible; otherwise
null
to indicate this node cannot be coerced.
-
numberValue
Description copied from class:JsonNode
Method that will try to access value of this node asNumber
that accurately represents its value, if (and only if) this is a number node (returnstrue
forJsonNode.isNumber()
). If this node is NOT a number node, aJsonNodeException
will be thrown.- Specified by:
numberValue
in classNumericNode
- Returns:
- Number value this node contains, if numeric node
-
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
-
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 that will try to access value of this node as a JavaBigDecimal
: but if node value cannot be expressed exactly as aBigDecimal
, aJsonNodeException
will be thrown. Access works for following cases:- All JSON Number values
NOTE: for more lenient conversions, use
JsonNode.asDecimal()
- Overrides:
decimalValue
in classNumericFPNode
- Returns:
BigDecimal
value this node represents, if possible to accurately represent
-
decimalValue
Description copied from class:JsonNode
Method similar toJsonNode.decimalValue()
, but that will returndefaultValue
if this node cannot be coerced to JavaBigDecimal
.- Overrides:
decimalValue
in classNumericFPNode
- 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
.- Overrides:
decimalValueOpt
in classNumericFPNode
- 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
- Overrides:
asDecimal
in classNumericFPNode
- 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
.- Overrides:
asDecimal
in classNumericFPNode
- 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
.- Overrides:
asDecimalOpt
in classNumericFPNode
- Returns:
- Java
BigDecimal
value this node represents, asOptional<BigDecimal>
, if possible to accurately represent;Optional.empty()
otherwise
-
_asShortValueUnchecked
protected short _asShortValueUnchecked()Description copied from class:NumericFPNode
Method for sub-classes to implement; returns the underlying value as ashort
without any checks (wrt NaN or value range), so caller must ensure validity prior to calling- Specified by:
_asShortValueUnchecked
in classNumericFPNode
-
_asIntValueUnchecked
protected int _asIntValueUnchecked()Description copied from class:NumericFPNode
Method for sub-classes to implement; returns the underlying value as aint
without any checks (wrt NaN or value range), so caller must ensure validity prior to calling- Specified by:
_asIntValueUnchecked
in classNumericFPNode
-
_asLongValueUnchecked
protected long _asLongValueUnchecked()Description copied from class:NumericFPNode
Method for sub-classes to implement; returns the underlying value as along
without any checks (wrt NaN or value range), so caller must ensure validity prior to calling- Specified by:
_asLongValueUnchecked
in classNumericFPNode
-
_asBigIntegerValueUnchecked
Description copied from class:NumericFPNode
Method for sub-classes to implement; returns the underlying value as aBigInteger
without any checks (wrt NaN), so caller must ensure validity prior to calling- Specified by:
_asBigIntegerValueUnchecked
in classNumericFPNode
-
_asDecimalValueUnchecked
Description copied from class:NumericFPNode
Method for sub-classes to implement; returns the underlying value as aBigDecimal
without any checks (wrt NaN), so caller must ensure validity prior to calling- Specified by:
_asDecimalValueUnchecked
in classNumericFPNode
-
_hasFractionalPart
protected boolean _hasFractionalPart()- Specified by:
_hasFractionalPart
in classNumericFPNode
-
_inShortRange
protected boolean _inShortRange()- Specified by:
_inShortRange
in classNumericFPNode
-
_inIntRange
protected boolean _inIntRange()- Specified by:
_inIntRange
in classNumericFPNode
-
_inLongRange
protected boolean _inLongRange()- Specified by:
_inLongRange
in classNumericFPNode
-
serialize
Description copied from class:BaseJsonNode
Method called to serialize node instances using given generator.- Specified by:
serialize
in interfaceJacksonSerializable
- Specified by:
serialize
in classBaseJsonNode
- Throws:
JacksonException
-
equals
Description copied from class:JsonNode
Equality 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
. -
hashCode
public int hashCode()- Specified by:
hashCode
in classBaseJsonNode
-