Top Description Fields Constructors Methods
tools.jackson.databind.node

public Class FloatNode

extends NumericFPNode
Class Inheritance
Imports
java.math.BigDecimal, .BigInteger, java.util.Optional, .OptionalDouble, tools.jackson.core.*, tools.jackson.core.io.NumberOutput, tools.jackson.databind.SerializationContext

JsonNode implementation for efficiently containing 32-bit `float` values.

Field Summary

Modifier and TypeField and Description
protected final float
private static final long

Constructor Summary

AccessConstructor and Description
public
FloatNode(float v)

Method Summary

Modifier and TypeMethod and Description
protected BigInteger
_asBigIntegerValueUnchecked()

Implements abstract tools.jackson.databind.node.NumericFPNode._asBigIntegerValueUnchecked.

Method for sub-classes to implement; returns the underlying value as a BigInteger without any checks (wrt NaN), so caller must ensure validity prior to calling

protected BigDecimal
_asDecimalValueUnchecked()

Implements abstract tools.jackson.databind.node.NumericFPNode._asDecimalValueUnchecked.

Method for sub-classes to implement; returns the underlying value as a BigDecimal without any checks (wrt NaN), so caller must ensure validity prior to calling

public int
_asIntValueUnchecked()

Implements abstract tools.jackson.databind.node.NumericNode._asIntValueUnchecked.

Method for sub-classes to implement; returns the underlying value as a int without any checks (wrt NaN or value range), so caller must ensure validity prior to calling

public long
_asLongValueUnchecked()

Implements abstract tools.jackson.databind.node.NumericNode._asLongValueUnchecked.

Method for sub-classes to implement; returns the underlying value as a long without any checks (wrt NaN or value range), so caller must ensure validity prior to calling

public short
_asShortValueUnchecked()

Implements abstract tools.jackson.databind.node.NumericNode._asShortValueUnchecked.

Method for sub-classes to implement; returns the underlying value as a short without any checks (wrt NaN or value range), so caller must ensure validity prior to calling

protected String
_asString()

Implements abstract tools.jackson.databind.node.NumericNode._asString.

Method sub-classes should override if they can produce String values via asString() -- if not, return null (in which case appropriate error will be thrown or default value returned).

public double
asDouble()

Implements abstract tools.jackson.databind.node.NumericNode.asDouble.

Method similar to 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
public double
asDouble(double defaultValue)

Implements abstract tools.jackson.databind.node.NumericNode.asDouble.

Method similar to asDouble(), but that will return defaultValue if this node cannot be coerced to double.

public OptionalDouble
asDoubleOpt()

Implements abstract tools.jackson.databind.node.NumericNode.asDoubleOpt.

Method similar to asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced to double.

public float
asFloat()

Implements abstract tools.jackson.databind.node.NumericNode.asFloat.

Method similar to 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
public float
asFloat(float defaultValue)

Implements abstract tools.jackson.databind.node.NumericNode.asFloat.

Method similar to asFloat(), but that will return defaultValue if this node cannot be coerced to float.

public Optional<Float>
asFloatOpt()

Implements abstract tools.jackson.databind.node.NumericNode.asFloatOpt.

Method similar to asFloat(), but that will return (Optional.empty()) if this node cannot be coerced to float.

public double
doubleValue()

Implements abstract tools.jackson.databind.node.NumericNode.doubleValue.

Method that will try to access value of this node as a double: but if node value cannot be expressed exactly as a double, a JsonNodeException will be thrown.

public double
doubleValue(double defaultValue)

Implements abstract tools.jackson.databind.node.NumericNode.doubleValue.

Method similar to doubleValue(), but that will return specified defaultValue if this node cannot be converted to double.

public OptionalDouble
doubleValueOpt()

Implements abstract tools.jackson.databind.node.NumericNode.doubleValueOpt.

Method similar to doubleValue(), but that will return empty OptionalLong (OptionalDouble.empty()) if this node cannot be converted to Java double.

public boolean
equals(Object o)

Implements abstract tools.jackson.databind.JsonNode.equals.

Equality for node objects is defined as full (deep) value equality.

public float
floatValue()

Implements abstract tools.jackson.databind.node.NumericNode.floatValue.

Method that will try to access value of this node as a Java float: but if node value cannot be expressed exactly as a float, a JsonNodeException will be thrown.

public float
floatValue(float defaultValue)

Implements abstract tools.jackson.databind.node.NumericNode.floatValue.

Method similar to floatValue(), but that will return specified defaultValue if this node cannot be converted to float.

public Optional<Float>
floatValueOpt()

Implements abstract tools.jackson.databind.node.NumericNode.floatValueOpt.

Method similar to floatValue(), but that will return empty Optional<Float> (Optional.empty()) if this node cannot be converted to Java float.

public boolean
hasFractionalPart()

Implements abstract tools.jackson.databind.node.NumericNode.hasFractionalPart.

Convenience method for checking whether this node is a NumericFPNode that contains non-zero fractional part (as opposed to only integer part).

public int
hashCode()

Implements abstract tools.jackson.databind.node.BaseJsonNode.hashCode.

Returns a hash code value for this object.

public boolean
inIntRange()

Implements abstract tools.jackson.databind.node.NumericNode.inIntRange.

Method that can be used to determine whether this numeric value's in part fits within Java 32-bitint type.

public boolean
inLongRange()

Implements abstract tools.jackson.databind.node.NumericNode.inLongRange.

Method that can be used to determine whether this numeric value's in part fits within Java 64-bit long type.

public boolean
inShortRange()

Implements abstract tools.jackson.databind.node.NumericNode.inShortRange.

Method that can be used to determine whether this numeric value's in part fits within Java 16-bit short type.

public boolean
public boolean
isNaN()

Implements abstract tools.jackson.databind.node.NumericNode.isNaN.

Convenience method for checking whether this node is a FloatNode or DoubleNode that contains "not-a-number" (NaN) value.

public JsonParser.NumberType
numberType()

Implements abstract tools.jackson.databind.node.NumericNode.numberType.

Implements tools.jackson.core.TreeNode.numberType.

Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.

public Number
numberValue()

Implements abstract tools.jackson.databind.node.NumericNode.numberValue.

Method that will try to access value of this node as Number that accurately represents its value, if (and only if) this is a number node (returns true for isNumber).

public final void
serialize(JsonGenerator g, SerializationContext provider)

Implements abstract tools.jackson.databind.node.BaseJsonNode.serialize.

Implements tools.jackson.databind.JacksonSerializable.serialize.

Method called to serialize node instances using given generator.

public static FloatNode
valueOf(float v)

Inherited from tools.jackson.databind.node.NumericFPNode:
asBigIntegerasBigIntegerasBigIntegerOptasDecimalasDecimalasDecimalOptasIntasIntasIntOptasLongasLongasLongOptasShortasShortasShortOptasTokenbigIntegerValuebigIntegerValuebigIntegerValueOptcanConvertToExactIntegralcanConvertToIntcanConvertToLongcanConvertToShortdecimalValuedecimalValuedecimalValueOptintValueintValueintValueOptisFloatingPointNumberlongValuelongValuelongValueOptshortValueshortValueshortValueOpt

Field Detail

_valueback to summary
protected final float _value
serialVersionUIDback to summary
private static final long serialVersionUID

Hides tools.jackson.databind.node.NumericFPNode.serialVersionUID.

Constructor Detail

FloatNodeback to summary
public FloatNode(float v)

Method Detail

_asBigIntegerValueUncheckedback to summary
protected BigInteger _asBigIntegerValueUnchecked()

Implements abstract tools.jackson.databind.node.NumericFPNode._asBigIntegerValueUnchecked.

Doc from tools.jackson.databind.node.NumericFPNode._asBigIntegerValueUnchecked.

Method for sub-classes to implement; returns the underlying value as a BigInteger without any checks (wrt NaN), so caller must ensure validity prior to calling

Annotations
@Override
_asDecimalValueUncheckedback to summary
protected BigDecimal _asDecimalValueUnchecked()

Implements abstract tools.jackson.databind.node.NumericFPNode._asDecimalValueUnchecked.

Doc from tools.jackson.databind.node.NumericFPNode._asDecimalValueUnchecked.

Method for sub-classes to implement; returns the underlying value as a BigDecimal without any checks (wrt NaN), so caller must ensure validity prior to calling

Annotations
@Override
_asIntValueUncheckedback to summary
public int _asIntValueUnchecked()

Implements abstract tools.jackson.databind.node.NumericNode._asIntValueUnchecked.

Doc from tools.jackson.databind.node.NumericNode._asIntValueUnchecked.

Method for sub-classes to implement; returns the underlying value as a int without any checks (wrt NaN or value range), so caller must ensure validity prior to calling

Annotations
@Override
_asLongValueUncheckedback to summary
public long _asLongValueUnchecked()

Implements abstract tools.jackson.databind.node.NumericNode._asLongValueUnchecked.

Doc from tools.jackson.databind.node.NumericNode._asLongValueUnchecked.

Method for sub-classes to implement; returns the underlying value as a long without any checks (wrt NaN or value range), so caller must ensure validity prior to calling

Annotations
@Override
_asShortValueUncheckedback to summary
public short _asShortValueUnchecked()

Implements abstract tools.jackson.databind.node.NumericNode._asShortValueUnchecked.

Doc from tools.jackson.databind.node.NumericNode._asShortValueUnchecked.

Method for sub-classes to implement; returns the underlying value as a short without any checks (wrt NaN or value range), so caller must ensure validity prior to calling

Annotations
@Override
_asStringback to summary
protected String _asString()

Implements abstract tools.jackson.databind.node.NumericNode._asString.

Doc from tools.jackson.databind.node.BaseJsonNode._asString.

Method sub-classes should override if they can produce String values via asString() -- if not, return null (in which case appropriate error will be thrown or default value returned).

Annotations
@Override
asDoubleback to summary
public double asDouble()

Implements abstract tools.jackson.databind.node.NumericNode.asDouble.

Doc from tools.jackson.databind.JsonNode.asDouble.

Method similar to 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

Annotations
@Override
asDoubleback to summary
public double asDouble(double defaultValue)

Implements abstract tools.jackson.databind.node.NumericNode.asDouble.

Doc from tools.jackson.databind.JsonNode.asDouble.

Method similar to asDouble(), but that will return defaultValue if this node cannot be coerced to double.

Annotations
@Override
asDoubleOptback to summary
public OptionalDouble asDoubleOpt()

Implements abstract tools.jackson.databind.node.NumericNode.asDoubleOpt.

Doc from tools.jackson.databind.JsonNode.asDoubleOpt.

Method similar to asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced to double.

Annotations
@Override
asFloatback to summary
public float asFloat()

Implements abstract tools.jackson.databind.node.NumericNode.asFloat.

Doc from tools.jackson.databind.JsonNode.asFloat.

Method similar to 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

Annotations
@Override
asFloatback to summary
public float asFloat(float defaultValue)

Implements abstract tools.jackson.databind.node.NumericNode.asFloat.

Doc from tools.jackson.databind.JsonNode.asFloat.

Method similar to asFloat(), but that will return defaultValue if this node cannot be coerced to float.

Annotations
@Override
asFloatOptback to summary
public Optional<Float> asFloatOpt()

Implements abstract tools.jackson.databind.node.NumericNode.asFloatOpt.

Doc from tools.jackson.databind.JsonNode.asFloatOpt.

Method similar to asFloat(), but that will return (Optional.empty()) if this node cannot be coerced to float.

Annotations
@Override
doubleValueback to summary
public double doubleValue()

Implements abstract tools.jackson.databind.node.NumericNode.doubleValue.

Doc from tools.jackson.databind.JsonNode.doubleValue.

Method that will try to access value of this node as a double: but if node value cannot be expressed exactly as a double, a JsonNodeException 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 asDouble()

Annotations
@Override
doubleValueback to summary
public double doubleValue(double defaultValue)

Implements abstract tools.jackson.databind.node.NumericNode.doubleValue.

Doc from tools.jackson.databind.JsonNode.doubleValue.

Method similar to doubleValue(), but that will return specified defaultValue if this node cannot be converted to double.

Annotations
@Override
doubleValueOptback to summary
public OptionalDouble doubleValueOpt()

Implements abstract tools.jackson.databind.node.NumericNode.doubleValueOpt.

Doc from tools.jackson.databind.JsonNode.doubleValueOpt.

Method similar to doubleValue(), but that will return empty OptionalLong (OptionalDouble.empty()) if this node cannot be converted to Java double.

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Implements abstract tools.jackson.databind.JsonNode.equals.

Doc from tools.jackson.databind.JsonNode.equals.

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 java.lang.Object.

Annotations
@Override
floatValueback to summary
public float floatValue()

Implements abstract tools.jackson.databind.node.NumericNode.floatValue.

Doc from tools.jackson.databind.JsonNode.floatValue.

Method that will try to access value of this node as a Java float: but if node value cannot be expressed exactly as a float, a JsonNodeException 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

Annotations
@Override
floatValueback to summary
public float floatValue(float defaultValue)

Implements abstract tools.jackson.databind.node.NumericNode.floatValue.

Doc from tools.jackson.databind.JsonNode.floatValue.

Method similar to floatValue(), but that will return specified defaultValue if this node cannot be converted to float.

Annotations
@Override
floatValueOptback to summary
public Optional<Float> floatValueOpt()

Implements abstract tools.jackson.databind.node.NumericNode.floatValueOpt.

Doc from tools.jackson.databind.JsonNode.floatValueOpt.

Method similar to floatValue(), but that will return empty Optional<Float> (Optional.empty()) if this node cannot be converted to Java float.

Annotations
@Override
hasFractionalPartback to summary
public boolean hasFractionalPart()

Implements abstract tools.jackson.databind.node.NumericNode.hasFractionalPart.

Doc from tools.jackson.databind.node.NumericNode.hasFractionalPart.

Convenience method for checking whether this node is a NumericFPNode that contains non-zero fractional part (as opposed to only integer part). Always returns false for integral NumericNodes (that is, {@ode NumericIntNode}s).

Annotations
@Override
hashCodeback to summary
public int hashCode()

Implements abstract tools.jackson.databind.node.BaseJsonNode.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
inIntRangeback to summary
public boolean inIntRange()

Implements abstract tools.jackson.databind.node.NumericNode.inIntRange.

Doc from tools.jackson.databind.node.NumericNode.inIntRange.

Method that can be used to determine whether this numeric value's in part fits within Java 32-bitint type.

Annotations
@Override
inLongRangeback to summary
public boolean inLongRange()

Implements abstract tools.jackson.databind.node.NumericNode.inLongRange.

Doc from tools.jackson.databind.node.NumericNode.inLongRange.

Method that can be used to determine whether this numeric value's in part fits within Java 64-bit long type.

Annotations
@Override
inShortRangeback to summary
public boolean inShortRange()

Implements abstract tools.jackson.databind.node.NumericNode.inShortRange.

Doc from tools.jackson.databind.node.NumericNode.inShortRange.

Method that can be used to determine whether this numeric value's in part fits within Java 16-bit short type.

Annotations
@Override
isFloatback to summary
public boolean isFloat()

Overrides tools.jackson.databind.JsonNode.isFloat.

Annotations
@Override
isNaNback to summary
public boolean isNaN()

Implements abstract tools.jackson.databind.node.NumericNode.isNaN.

Doc from tools.jackson.databind.node.NumericNode.isNaN.

Convenience method for checking whether this node is a FloatNode or DoubleNode that contains "not-a-number" (NaN) value.

Annotations
@Override
numberTypeback to summary
public JsonParser.NumberType numberType()

Implements abstract tools.jackson.databind.node.NumericNode.numberType.

Implements tools.jackson.core.TreeNode.numberType.

Doc from tools.jackson.databind.node.BaseJsonNode.numberType.

Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.

Annotations
@Override
numberValueback to summary
public Number numberValue()

Implements abstract tools.jackson.databind.node.NumericNode.numberValue.

Doc from tools.jackson.databind.JsonNode.numberValue.

Method that will try to access value of this node as Number that accurately represents its value, if (and only if) this is a number node (returns true for isNumber). If this node is NOT a number node, a JsonNodeException will be thrown.

Annotations
@Override
serializeback to summary
public final void serialize(JsonGenerator g, SerializationContext provider) throws JacksonException

Implements abstract tools.jackson.databind.node.BaseJsonNode.serialize.

Implements tools.jackson.databind.JacksonSerializable.serialize.

Doc from tools.jackson.databind.node.BaseJsonNode.serialize.

Method called to serialize node instances using given generator.

Annotations
@Override
valueOfback to summary
public static FloatNode valueOf(float v)