- All Implemented Interfaces:
Serializable,Iterable<JsonNode>,TreeNode,JacksonSerializable
JsonNode implementation for efficiently containing 32-bit
`float` values.- 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 BigIntegerMethod for sub-classes to implement; returns the underlying value as aBigIntegerwithout any checks (wrt NaN), so caller must ensure validity prior to callingprotected BigDecimalMethod for sub-classes to implement; returns the underlying value as aBigDecimalwithout any checks (wrt NaN), so caller must ensure validity prior to callingprotected intMethod for sub-classes to implement; returns the underlying value as aintwithout any checks (wrt NaN or value range), so caller must ensure validity prior to callingprotected longMethod for sub-classes to implement; returns the underlying value as alongwithout any checks (wrt NaN or value range), so caller must ensure validity prior to callingprotected shortMethod for sub-classes to implement; returns the underlying value as ashortwithout any checks (wrt NaN or value range), so caller must ensure validity prior to callingprotected 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 booleanprotected booleanprotected booleanprotected booleandoubleasDouble()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.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.booleanEquality for node objects is defined as full (deep) value equality.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.inthashCode()booleanisFloat()booleanisNaN()Convenience method for checking whether this node is aFloatNodeorDoubleNodethat 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 asNumberthat accurately represents its value, if (and only if) this is a number node (returnstrueforJsonNode.isNumber()).final voidserialize(JsonGenerator g, SerializationContext provider) Method called to serialize node instances using given generator.static FloatNodevalueOf(float v) Methods inherited from class tools.jackson.databind.node.NumericFPNode
asBigInteger, asBigInteger, asBigIntegerOpt, asDecimal, asDecimal, asDecimalOpt, asInt, asInt, asIntOpt, asLong, asLong, asLongOpt, asShort, asShort, asShortOpt, asToken, bigIntegerValue, bigIntegerValue, bigIntegerValueOpt, canConvertToExactIntegral, canConvertToInt, canConvertToLong, canConvertToShort, decimalValue, decimalValue, decimalValueOpt, intValue, intValue, intValueOpt, isFloatingPointNumber, longValue, longValue, longValueOpt, shortValue, shortValue, shortValueOptMethods inherited from class tools.jackson.databind.node.NumericNode
_valueDesc, deepCopy, getNodeTypeMethods 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, isEmbeddedValue, isMissingNode, required, required, stringValue, stringValue, stringValueOpt, toPrettyString, toString, traverse, withArray, withObjectMethods inherited from class tools.jackson.databind.JsonNode
_reportRequiredViolation, _reportUnsupportedOperation, _this, asOptional, asText, asText, at, at, equals, findParents, findValues, findValuesAsString, forEachEntry, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainer, isDouble, 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, withObjectPropertyMethods inherited from class tools.jackson.databind.JacksonSerializable.Base
isEmpty
-
Field Details
-
_value
protected final float _value
-
-
Constructor Details
-
FloatNode
public FloatNode(float v)
-
-
Method Details
-
valueOf
-
numberType
Description copied from class:BaseJsonNodeReturns code that identifies type of underlying numeric value, if (and only if) node is a number node.- Specified by:
numberTypein interfaceTreeNode- Specified by:
numberTypein classNumericNode
-
isFloat
public boolean isFloat() -
isNaN
public 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
-
_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).- Specified by:
_asStringin classNumericNode- Returns:
- Coerced value if possible; otherwise
nullto indicate this node cannot be coerced.
-
numberValue
Description copied from class:JsonNodeMethod that will try to access value of this node asNumberthat accurately represents its value, if (and only if) this is a number node (returnstrueforJsonNode.isNumber()). If this node is NOT a number node, aJsonNodeExceptionwill be thrown.- Specified by:
numberValuein classNumericNode- Returns:
- Number value this node contains, if numeric node
-
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
-
_asShortValueUnchecked
protected short _asShortValueUnchecked()Description copied from class:NumericFPNodeMethod for sub-classes to implement; returns the underlying value as ashortwithout any checks (wrt NaN or value range), so caller must ensure validity prior to calling- Specified by:
_asShortValueUncheckedin classNumericFPNode
-
_asIntValueUnchecked
protected int _asIntValueUnchecked()Description copied from class:NumericFPNodeMethod for sub-classes to implement; returns the underlying value as aintwithout any checks (wrt NaN or value range), so caller must ensure validity prior to calling- Specified by:
_asIntValueUncheckedin classNumericFPNode
-
_asLongValueUnchecked
protected long _asLongValueUnchecked()Description copied from class:NumericFPNodeMethod for sub-classes to implement; returns the underlying value as alongwithout any checks (wrt NaN or value range), so caller must ensure validity prior to calling- Specified by:
_asLongValueUncheckedin classNumericFPNode
-
_asBigIntegerValueUnchecked
Description copied from class:NumericFPNodeMethod for sub-classes to implement; returns the underlying value as aBigIntegerwithout any checks (wrt NaN), so caller must ensure validity prior to calling- Specified by:
_asBigIntegerValueUncheckedin classNumericFPNode
-
_asDecimalValueUnchecked
Description copied from class:NumericFPNodeMethod for sub-classes to implement; returns the underlying value as aBigDecimalwithout any checks (wrt NaN), so caller must ensure validity prior to calling- Specified by:
_asDecimalValueUncheckedin classNumericFPNode
-
_hasFractionalPart
protected boolean _hasFractionalPart()- Specified by:
_hasFractionalPartin classNumericFPNode
-
_inShortRange
protected boolean _inShortRange()- Specified by:
_inShortRangein classNumericFPNode
-
_inIntRange
protected boolean _inIntRange()- Specified by:
_inIntRangein classNumericFPNode
-
_inLongRange
protected boolean _inLongRange()- Specified by:
_inLongRangein classNumericFPNode
-
serialize
Description copied from class:BaseJsonNodeMethod called to serialize node instances using given generator.- Specified by:
serializein interfaceJacksonSerializable- Specified by:
serializein classBaseJsonNode- Throws:
JacksonException
-
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. -
hashCode
public int hashCode()- Specified by:
hashCodein classBaseJsonNode
-