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

public abstract Class NumericIntNode

extends NumericNode
Class Inheritance
Known Direct Subclasses
tools.jackson.databind.node.ShortNode, tools.jackson.databind.node.BigIntegerNode, tools.jackson.databind.node.IntNode, tools.jackson.databind.node.LongNode
Imports
java.math.BigDecimal, .BigInteger, java.util.Optional, .OptionalDouble, tools.jackson.core.JsonToken

Intermediate node class used for numeric nodes that contain integral values: provides partial implementation of common methods.

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract double
protected abstract float
public BigInteger
asBigInteger()

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

Method similar to bigIntegerValue() but in addition to coercing Number values (same as 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 bigIntegerValue()) will be truncated to integer value (like with BigDecimal#toBigInteger()))
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public BigInteger
asBigInteger(BigInteger defaultValue)

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

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

public Optional<BigInteger>
asBigIntegerOpt()

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

Method similar to bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.

public BigDecimal
asDecimal()

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

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

public BigDecimal
asDecimal(BigDecimal defaultValue)

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

Method similar to asDecimal(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.

public Optional<BigDecimal>
asDecimalOpt()

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

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

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 final JsonToken
asToken()

Implements abstract tools.jackson.databind.node.ValueNode.asToken.

Implements tools.jackson.core.TreeNode.asToken.

Method that can be used for efficient type detection when using stream abstraction for traversing nodes.

public abstract BigInteger
bigIntegerValue()

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

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

public BigInteger
bigIntegerValue(BigInteger defaultValue)

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

Method similar to bigIntegerValue(), but that will return specified defaultValue if this node cannot be converted to Java BigInteger.

public Optional<BigInteger>
bigIntegerValueOpt()

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

Method similar to bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.

public final boolean
canConvertToInt()

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

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to int (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).

public final boolean
canConvertToLong()

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

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to long (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).

public final boolean
canConvertToShort()

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

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to short (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).

public BigDecimal
decimalValue(BigDecimal defaultValue)

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

Method similar to decimalValue(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.

public Optional<BigDecimal>
decimalValueOpt()

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

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

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 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 final boolean
public final 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.

Inherited from tools.jackson.databind.node.NumericNode:
_asIntValueUnchecked_asLongValueUnchecked_asShortValueUnchecked_asString_valueDescasIntasIntasIntOptasLongasLongasLongOptasShortasShortasShortOptdecimalValuedeepCopygetNodeTypeinIntRangeinLongRangeinShortRangeintValueintValueintValueOptlongValuelongValuelongValueOptnumberTypenumberValueshortValueshortValueshortValueOpt

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides tools.jackson.databind.node.NumericNode.serialVersionUID.

Constructor Detail

NumericIntNodeback to summary
public NumericIntNode()

Method Detail

_asDoubleValueUncheckedback to summary
protected abstract double _asDoubleValueUnchecked()
_asFloatValueUncheckedback to summary
protected abstract float _asFloatValueUnchecked()
asBigIntegerback to summary
public BigInteger asBigInteger()

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

Doc from tools.jackson.databind.JsonNode.asBigInteger.

Method similar to bigIntegerValue() but in addition to coercing Number values (same as 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 bigIntegerValue()) will be truncated to integer value (like with BigDecimal#toBigInteger()))
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
Annotations
@Override
asBigIntegerback to summary
public BigInteger asBigInteger(BigInteger defaultValue)

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

Doc from tools.jackson.databind.JsonNode.asBigInteger.

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

Annotations
@Override
asBigIntegerOptback to summary
public Optional<BigInteger> asBigIntegerOpt()

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

Doc from tools.jackson.databind.JsonNode.asBigIntegerOpt.

Method similar to bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.

Annotations
@Override
asDecimalback to summary
public BigDecimal asDecimal()

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

Doc from tools.jackson.databind.JsonNode.asDecimal.

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

Annotations
@Override
asDecimalback to summary
public BigDecimal asDecimal(BigDecimal defaultValue)

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

Doc from tools.jackson.databind.JsonNode.asDecimal.

Method similar to asDecimal(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.

Annotations
@Override
asDecimalOptback to summary
public Optional<BigDecimal> asDecimalOpt()

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

Doc from tools.jackson.databind.JsonNode.asDecimalOpt.

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

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
asTokenback to summary
public final JsonToken asToken()

Implements abstract tools.jackson.databind.node.ValueNode.asToken.

Implements tools.jackson.core.TreeNode.asToken.

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

Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the first JsonToken that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)

Annotations
@Override
bigIntegerValueback to summary
public abstract BigInteger bigIntegerValue()

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

Doc from tools.jackson.databind.JsonNode.bigIntegerValue.

Method that will try to access value of this node as a BigInteger, but if node value cannot be expressed exactly as a BigInteger, a JsonNodeException will be thrown. Access works for following cases:

  • JSON Integer values
  • JSON Floating-point values that do not have fractional part.

Annotations
@Override
bigIntegerValueback to summary
public BigInteger bigIntegerValue(BigInteger defaultValue)

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

Doc from tools.jackson.databind.JsonNode.bigIntegerValue.

Method similar to bigIntegerValue(), but that will return specified defaultValue if this node cannot be converted to Java BigInteger.

Annotations
@Override
bigIntegerValueOptback to summary
public Optional<BigInteger> bigIntegerValueOpt()

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

Doc from tools.jackson.databind.JsonNode.bigIntegerValueOpt.

Method similar to bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.

Annotations
@Override
canConvertToIntback to summary
public final boolean canConvertToInt()

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

Doc from tools.jackson.databind.JsonNode.canConvertToInt.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to int (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 asInt could still succeed.

Annotations
@Override
canConvertToLongback to summary
public final boolean canConvertToLong()

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

Doc from tools.jackson.databind.JsonNode.canConvertToLong.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to long (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 asLong could still succeed.

Annotations
@Override
canConvertToShortback to summary
public final boolean canConvertToShort()

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

Doc from tools.jackson.databind.JsonNode.canConvertToShort.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to short (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 asShort could still succeed.

Annotations
@Override
decimalValueback to summary
public BigDecimal decimalValue(BigDecimal defaultValue)

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

Doc from tools.jackson.databind.JsonNode.decimalValue.

Method similar to decimalValue(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.

Annotations
@Override
decimalValueOptback to summary
public Optional<BigDecimal> decimalValueOpt()

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

Doc from tools.jackson.databind.JsonNode.decimalValueOpt.

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

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
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
isIntegralNumberback to summary
public final boolean isIntegralNumber()

Overrides tools.jackson.databind.JsonNode.isIntegralNumber.

Annotations
@Override
isNaNback to summary
public final 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