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

public abstract Class NumericFPNode

extends NumericNode
Class Inheritance
Known Direct Subclasses
tools.jackson.databind.node.DecimalNode, tools.jackson.databind.node.DoubleNode, tools.jackson.databind.node.FloatNode
Imports
java.math.BigDecimal, .BigInteger, java.util.Optional, .OptionalInt, .OptionalLong, tools.jackson.core.JsonToken

Intermediate node class used for numeric nodes that contain floating-point 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 BigInteger
_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 abstract BigDecimal
_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 final 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 final 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 final 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 int
asInt()

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

Method similar to intValue() but in addition to coercing Number values (same as intValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for intValue()) will be truncated to int (if (and only if) they fit in int range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public int
asInt(int defaultValue)

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

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

public OptionalInt
asIntOpt()

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

Method similar to asInt(), but that will return (OptionalInt.empty()) if this node cannot be coerced to int.

public final long
asLong()

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

Method similar to longValue() but in addition to coercing Number values (same as longValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for longValue()) will be truncated to long (if (and only if) they fit in long range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public final long
asLong(long defaultValue)

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

Method similar to asLong(), but that will return specified defaultValue if this node cannot be coerced to long (instead of throwing an exception).

public final OptionalLong
asLongOpt()

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

Method similar to asLong(), but that will return (OptionalLong.empty()) if this node cannot be coerced to long.

public short
asShort()

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

Method similar to shortValue() but in addition to coercing Number values (same as shortValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for shortValue()) will be truncated to short (if (and only if) they fit in short range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public short
asShort(short defaultValue)

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

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

public Optional<Short>
asShortOpt()

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

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

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 final 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 final 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 final 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
canConvertToExactIntegral()

Overrides tools.jackson.databind.JsonNode.canConvertToExactIntegral.

Method that can be used to check whether contained value is numeric (returns true for isNumber()) and can be converted without loss to integral number (specifically, BigInteger but potentially others, see canConvertToInt and canConvertToInt).

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()

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

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

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 final int
intValue()

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

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

public final int
intValue(int defaultValue)

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

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

public final OptionalInt
intValueOpt()

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

Method similar to intValue(), but that will return empty OptionalInt (OptionalInt.empty()) if this node cannot be converted to Java int.

public final boolean
public final long
longValue()

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

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

public final long
longValue(long defaultValue)

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

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

public final OptionalLong
longValueOpt()

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

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

public final short
shortValue()

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

Method that will try to access value of this node as 16-bit signed integer value (Java short): but if node value cannot be expressed exactly as a short, a JsonNodeException will be thrown.

public final short
shortValue(short defaultValue)

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

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

public final Optional<Short>
shortValueOpt()

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

Method similar to shortValue(), but that will return empty Optional<Short> (Optional.empty()) if this node cannot be converted to Java short.

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

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

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

Constructor Detail

NumericFPNodeback to summary
public NumericFPNode()

Method Detail

_asBigIntegerValueUncheckedback to summary
protected abstract BigInteger _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

_asDecimalValueUncheckedback to summary
protected abstract BigDecimal _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

asBigIntegerback to summary
public final 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 final 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 final 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
asIntback to summary
public int asInt()

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

Doc from tools.jackson.databind.JsonNode.asInt.

Method similar to intValue() but in addition to coercing Number values (same as intValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for intValue()) will be truncated to int (if (and only if) they fit in int range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
Annotations
@Override
asIntback to summary
public int asInt(int defaultValue)

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

Doc from tools.jackson.databind.JsonNode.asInt.

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

Annotations
@Override
asIntOptback to summary
public OptionalInt asIntOpt()

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

Doc from tools.jackson.databind.JsonNode.asIntOpt.

Method similar to asInt(), but that will return (OptionalInt.empty()) if this node cannot be coerced to int.

Annotations
@Override
asLongback to summary
public final long asLong()

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

Doc from tools.jackson.databind.JsonNode.asLong.

Method similar to longValue() but in addition to coercing Number values (same as longValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for longValue()) will be truncated to long (if (and only if) they fit in long range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
Annotations
@Override
asLongback to summary
public final long asLong(long defaultValue)

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

Doc from tools.jackson.databind.JsonNode.asLong.

Method similar to asLong(), but that will return specified defaultValue if this node cannot be coerced to long (instead of throwing an exception).

Annotations
@Override
asLongOptback to summary
public final OptionalLong asLongOpt()

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

Doc from tools.jackson.databind.JsonNode.asLongOpt.

Method similar to asLong(), but that will return (OptionalLong.empty()) if this node cannot be coerced to long.

Annotations
@Override
asShortback to summary
public short asShort()

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

Doc from tools.jackson.databind.JsonNode.asShort.

Method similar to shortValue() but in addition to coercing Number values (same as shortValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for shortValue()) will be truncated to short (if (and only if) they fit in short range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
Annotations
@Override
asShortback to summary
public short asShort(short defaultValue)

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

Doc from tools.jackson.databind.JsonNode.asShort.

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

Annotations
@Override
asShortOptback to summary
public Optional<Short> asShortOpt()

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

Doc from tools.jackson.databind.JsonNode.asShortOpt.

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

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 final 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 final 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 final 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
canConvertToExactIntegralback to summary
public final boolean canConvertToExactIntegral()

Overrides tools.jackson.databind.JsonNode.canConvertToExactIntegral.

Doc from tools.jackson.databind.JsonNode.canConvertToExactIntegral.

Method that can be used to check whether contained value is numeric (returns true for isNumber()) and can be converted without loss to integral number (specifically, BigInteger but potentially others, see canConvertToInt and canConvertToInt). Latter part allows floating-point numbers (for which isFloatingPointNumber() returns true) that do not have fractional part. Note that "not-a-number" values of double and float will return false as they cannot be converted to matching integral representations.

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()

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

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

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

  • All JSON Number values

Note

for more lenient conversions, use asDecimal()

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
intValueback to summary
public final int intValue()

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

Doc from tools.jackson.databind.JsonNode.intValue.

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

  • JSON Integer values that fit in Java 32-bit signed int range
  • JSON Floating-point values that fit in Java 32-bit signed int range AND do not have fractional part.

Note

for more lenient conversions, use asInt()

Annotations
@Override
intValueback to summary
public final int intValue(int defaultValue)

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

Doc from tools.jackson.databind.JsonNode.intValue.

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

Annotations
@Override
intValueOptback to summary
public final OptionalInt intValueOpt()

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

Doc from tools.jackson.databind.JsonNode.intValueOpt.

Method similar to intValue(), but that will return empty OptionalInt (OptionalInt.empty()) if this node cannot be converted to Java int.

Annotations
@Override
isFloatingPointNumberback to summary
public final boolean isFloatingPointNumber()

Overrides tools.jackson.databind.JsonNode.isFloatingPointNumber.

Annotations
@Override
longValueback to summary
public final long longValue()

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

Doc from tools.jackson.databind.JsonNode.longValue.

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

  • JSON Integer values that fit in Java 64-bit signed long range
  • JSON Floating-point values that fit in Java 64-bit signed long range AND do not have fractional part.

Note

for more lenient conversions, use asLong()

Annotations
@Override
longValueback to summary
public final long longValue(long defaultValue)

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

Doc from tools.jackson.databind.JsonNode.longValue.

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

Annotations
@Override
longValueOptback to summary
public final OptionalLong longValueOpt()

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

Doc from tools.jackson.databind.JsonNode.longValueOpt.

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

Annotations
@Override
shortValueback to summary
public final short shortValue()

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

Doc from tools.jackson.databind.JsonNode.shortValue.

Method that will try to access value of this node as 16-bit signed integer value (Java short): but if node value cannot be expressed exactly as a short, a JsonNodeException will be thrown. Access works for following cases:

  • JSON Integer values that fit in Java 16-bit signed short range
  • JSON Floating-point values that fit in Java 16-bit signed short range AND do not have fractional part.

Annotations
@Override
shortValueback to summary
public final short shortValue(short defaultValue)

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

Doc from tools.jackson.databind.JsonNode.shortValue.

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

Annotations
@Override
shortValueOptback to summary
public final Optional<Short> shortValueOpt()

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

Doc from tools.jackson.databind.JsonNode.shortValueOpt.

Method similar to shortValue(), but that will return empty Optional<Short> (Optional.empty()) if this node cannot be converted to Java short.

Annotations
@Override