Class BigIntegerNode

All Implemented Interfaces:
Serializable, Iterable<JsonNode>, TreeNode, JacksonSerializable

public class BigIntegerNode extends NumericIntNode
Numeric node that contains simple 64-bit integer values.
See Also:
  • Field Details

  • Constructor Details

    • BigIntegerNode

      public BigIntegerNode(BigInteger v)
  • Method Details

    • valueOf

      public static BigIntegerNode valueOf(BigInteger v)
    • numberType

      public JsonParser.NumberType 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 interface TreeNode
      Specified by:
      numberType in class NumericNode
    • isBigInteger

      public boolean isBigInteger()
      Overrides:
      isBigInteger in class JsonNode
    • _asBoolean

      protected Boolean _asBoolean()
      Description copied from class: BaseJsonNode
      Method sub-classes should override if they can produce boolean values via BaseJsonNode.asBoolean() -- if not, return null (in which case appropriate error will be thrown or default value returned).
      Overrides:
      _asBoolean in class BaseJsonNode
      Returns:
      Coerced value if possible; otherwise null to indicate this node cannot be coerced.
    • _asString

      public String _asString()
      Description copied from class: BaseJsonNode
      Method sub-classes should override if they can produce String values via BaseJsonNode.asString() -- if not, return null (in which case appropriate error will be thrown or default value returned).
      Specified by:
      _asString in class NumericNode
      Returns:
      Coerced value if possible; otherwise null to indicate this node cannot be coerced.
    • numberValue

      public Number numberValue()
      Description copied from class: JsonNode
      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 JsonNode.isNumber()). If this node is NOT a number node, a JsonNodeException will be thrown.
      Specified by:
      numberValue in class NumericNode
      Returns:
      Number value this node contains, if numeric node
    • shortValue

      public short shortValue()
      Description copied from class: JsonNode
      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.

      Specified by:
      shortValue in class NumericNode
      Returns:
      Short value this node represents, if possible to accurately represent
    • shortValue

      public short shortValue(short defaultValue)
      Description copied from class: JsonNode
      Method similar to JsonNode.shortValue(), but that will return specified defaultValue if this node cannot be converted to Java short.
      Specified by:
      shortValue in class NumericNode
      Parameters:
      defaultValue - Value to return if this node cannot be converted to Java short
      Returns:
      Java short value this node represents, if possible to accurately represent; defaultValue otherwise
    • asShort

      public short asShort()
      Description copied from class: JsonNode
      Method similar to JsonNode.shortValue() but in addition to coercing Number values (same as JsonNode.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 JsonNode.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
      Specified by:
      asShort in class NumericNode
      Returns:
      short value this node represents, if possible to accurately represent
    • asShort

      public short asShort(short defaultValue)
      Description copied from class: JsonNode
      Method similar to JsonNode.shortValue(), but that will return specified defaultValue if this node cannot be converted to short.
      Specified by:
      asShort in class NumericNode
      Parameters:
      defaultValue - Value to return if this node cannot be converted to short
      Returns:
      short value this node represents, if possible to accurately represent; defaultValue otherwise
    • intValue

      public int intValue()
      Description copied from class: JsonNode
      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 JsonNode.asInt()

      Specified by:
      intValue in class NumericNode
      Returns:
      Int value this node represents, if possible to accurately represent
    • intValue

      public int intValue(int defaultValue)
      Description copied from class: JsonNode
      Method similar to JsonNode.intValue(), but that will return specified defaultValue if this node cannot be converted to Java int.
      Specified by:
      intValue in class NumericNode
      Parameters:
      defaultValue - Value to return if this node cannot be converted to Java int
      Returns:
      Java int value this node represents, if possible to accurately represent; defaultValue otherwise
    • intValueOpt

      public OptionalInt intValueOpt()
      Description copied from class: JsonNode
      Method similar to JsonNode.intValue(), but that will return empty OptionalInt (OptionalInt.empty()) if this node cannot be converted to Java int.
      Specified by:
      intValueOpt in class NumericNode
      Returns:
      Java int value this node represents, as OptionalInt, if possible to accurately represent; OptionalInt.empty() otherwise
    • asInt

      public int asInt()
      Description copied from class: JsonNode
      Method similar to JsonNode.intValue() but in addition to coercing Number values (same as JsonNode.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 JsonNode.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
      Specified by:
      asInt in class NumericNode
      Returns:
      int value this node represents, if possible to accurately represent
    • asInt

      public int asInt(int defaultValue)
      Description copied from class: JsonNode
      Method similar to JsonNode.intValue(), but that will return specified defaultValue if this node cannot be converted to int.
      Specified by:
      asInt in class NumericNode
      Parameters:
      defaultValue - Value to return if this node cannot be converted to int
      Returns:
      int value this node represents, if possible to accurately represent; defaultValue otherwise
    • asIntOpt

      public OptionalInt asIntOpt()
      Description copied from class: JsonNode
      Method similar to JsonNode.asInt(), but that will return (OptionalInt.empty()) if this node cannot be coerced to int.
      Specified by:
      asIntOpt in class NumericNode
      Returns:
      OptionalInt value this node represents, if possible to accurately represent; OptionalInt.empty() otherwise
    • longValue

      public long longValue()
      Description copied from class: JsonNode
      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 JsonNode.asLong()

      Specified by:
      longValue in class NumericNode
      Returns:
      Long value this node represents, if possible to accurately represent
    • longValue

      public long longValue(long defaultValue)
      Description copied from class: JsonNode
      Method similar to JsonNode.longValue(), but that will return specified defaultValue if this node cannot be converted to long.
      Specified by:
      longValue in class NumericNode
      Parameters:
      defaultValue - Value to return if this node cannot be converted to long
      Returns:
      long value this node represents, if possible to accurately represent; defaultValue otherwise
    • longValueOpt

      public OptionalLong longValueOpt()
      Description copied from class: JsonNode
      Method similar to JsonNode.longValue(), but that will return empty OptionalLong (OptionalLong.empty()) if this node cannot be converted to Java long.
      Specified by:
      longValueOpt in class NumericNode
      Returns:
      Java long value this node represents, as OptionalLong, if possible to accurately represent; OptionalLong.empty() otherwise
    • asLong

      public long asLong()
      Description copied from class: JsonNode
      Method similar to JsonNode.longValue() but in addition to coercing Number values (same as JsonNode.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 JsonNode.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
      Specified by:
      asLong in class NumericNode
      Returns:
      long value this node represents, if possible to accurately represent
    • asLong

      public long asLong(long defaultValue)
      Description copied from class: JsonNode
      Method similar to JsonNode.asLong(), but that will return specified defaultValue if this node cannot be coerced to long (instead of throwing an exception).
      Specified by:
      asLong in class NumericNode
      Parameters:
      defaultValue - Value to return if this node cannot be coerced to long
      Returns:
      long value this node represents, if possible to accurately represent; defaultValue otherwise
    • asLongOpt

      public OptionalLong asLongOpt()
      Description copied from class: JsonNode
      Method similar to JsonNode.asLong(), but that will return (OptionalLong.empty()) if this node cannot be coerced to long.
      Specified by:
      asLongOpt in class NumericNode
      Returns:
      OptionalLong value this node represents (or can be coerced to), OptionalLong.empty() otherwise
    • bigIntegerValue

      public BigInteger bigIntegerValue()
      Description copied from class: JsonNode
      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.

      Specified by:
      bigIntegerValue in class NumericIntNode
      Returns:
      BigInteger value this node represents, if possible to accurately represent
    • bigIntegerValue

      public BigInteger bigIntegerValue(BigInteger defaultValue)
      Description copied from class: JsonNode
      Method similar to JsonNode.bigIntegerValue(), but that will return specified defaultValue if this node cannot be converted to Java BigInteger.
      Overrides:
      bigIntegerValue in class NumericIntNode
      Parameters:
      defaultValue - Value to return if this node cannot be converted to Java BigInteger
      Returns:
      Java BigInteger value this node represents, if possible to accurately represent; defaultValue otherwise
    • bigIntegerValueOpt

      public Optional<BigInteger> bigIntegerValueOpt()
      Description copied from class: JsonNode
      Method similar to JsonNode.bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.
      Overrides:
      bigIntegerValueOpt in class NumericIntNode
      Returns:
      Java BigInteger value this node represents, as Optional<BigInteger>, if possible to accurately represent; Optional.empty() otherwise
    • floatValue

      public float floatValue()
      Description copied from class: JsonNode
      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

      Overrides:
      floatValue in class NumericIntNode
      Returns:
      Float value this node represents, if possible to accurately represent
    • floatValue

      public float floatValue(float defaultValue)
      Description copied from class: JsonNode
      Method similar to JsonNode.floatValue(), but that will return specified defaultValue if this node cannot be converted to float.
      Overrides:
      floatValue in class NumericIntNode
      Parameters:
      defaultValue - Value to return if this node cannot be converted to float
      Returns:
      float value this node represents, if possible to accurately represent; defaultValue otherwise
    • asFloat

      public float asFloat()
      Description copied from class: JsonNode
      Method similar to JsonNode.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

      Overrides:
      asFloat in class NumericIntNode
      Returns:
      float value this node represents, if possible to accurately represent
    • asFloat

      public float asFloat(float defaultValue)
      Description copied from class: JsonNode
      Method similar to JsonNode.asFloat(), but that will return defaultValue if this node cannot be coerced to float.
      Overrides:
      asFloat in class NumericIntNode
      Returns:
      float value this node represents, if possible to accurately represent; defaultValue otherwise
    • doubleValue

      public double doubleValue()
      Description copied from class: JsonNode
      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 JsonNode.asDouble()

      Overrides:
      doubleValue in class NumericIntNode
      Returns:
      Double value this node represents, if possible to accurately represent
    • doubleValue

      public double doubleValue(double defaultValue)
      Description copied from class: JsonNode
      Method similar to JsonNode.doubleValue(), but that will return specified defaultValue if this node cannot be converted to double.
      Overrides:
      doubleValue in class NumericIntNode
      Parameters:
      defaultValue - Value to return if this node cannot be converted to double
      Returns:
      double value this node represents, if possible to accurately represent; defaultValue otherwise
    • doubleValueOpt

      public OptionalDouble doubleValueOpt()
      Description copied from class: JsonNode
      Method similar to JsonNode.doubleValue(), but that will return empty OptionalLong (OptionalDouble.empty()) if this node cannot be converted to Java double.
      Overrides:
      doubleValueOpt in class NumericIntNode
      Returns:
      Java double value this node represents, as OptionalDouble, if possible to accurately represent; OptionalDouble.empty() otherwise
    • asDouble

      public double asDouble()
      Description copied from class: JsonNode
      Method similar to JsonNode.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

      Overrides:
      asDouble in class NumericIntNode
      Returns:
      double value this node represents, if possible to accurately represent
    • asDouble

      public double asDouble(double defaultValue)
      Description copied from class: JsonNode
      Method similar to JsonNode.asDouble(), but that will return defaultValue if this node cannot be coerced to double.
      Overrides:
      asDouble in class NumericIntNode
      Returns:
      double value this node represents, if possible to accurately represent; defaultValue otherwise
    • asDoubleOpt

      public OptionalDouble asDoubleOpt()
      Description copied from class: JsonNode
      Method similar to JsonNode.asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced to double.
      Overrides:
      asDoubleOpt in class NumericIntNode
      Returns:
      OptionalDouble value this node represents, if possible to accurately represent; OptionalDouble.empty() otherwise
    • decimalValue

      public BigDecimal decimalValue()
      Description copied from class: JsonNode
      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 JsonNode.asDecimal()

      Specified by:
      decimalValue in class NumericNode
      Returns:
      BigDecimal value this node represents, if possible to accurately represent
    • decimalValue

      public BigDecimal decimalValue(BigDecimal defaultValue)
      Description copied from class: JsonNode
      Method similar to JsonNode.decimalValue(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.
      Overrides:
      decimalValue in class NumericIntNode
      Returns:
      BigDecimal value this node represents, if possible to accurately represent; defaultValue otherwise
    • decimalValueOpt

      public Optional<BigDecimal> decimalValueOpt()
      Description copied from class: JsonNode
      Method similar to JsonNode.decimalValue(), but that will return empty Optional (Optional.empty()) if this node cannot be coerced to BigDecimal.
      Overrides:
      decimalValueOpt in class NumericIntNode
      Returns:
      Java BigDecimal value this node represents, as Optional<BigDecimal>, if possible to accurately represent; Optional.empty() otherwise
    • _asIntValueUnchecked

      protected int _asIntValueUnchecked()
      Specified by:
      _asIntValueUnchecked in class NumericIntNode
    • _asFloatValueUnchecked

      protected float _asFloatValueUnchecked()
      Specified by:
      _asFloatValueUnchecked in class NumericIntNode
    • _asDoubleValueUnchecked

      protected double _asDoubleValueUnchecked()
      Specified by:
      _asDoubleValueUnchecked in class NumericIntNode
    • _inShortRange

      protected boolean _inShortRange()
      Specified by:
      _inShortRange in class NumericIntNode
    • _inIntRange

      public boolean _inIntRange()
      Specified by:
      _inIntRange in class NumericIntNode
    • _inLongRange

      protected boolean _inLongRange()
      Specified by:
      _inLongRange in class NumericIntNode
    • serialize

      public final void serialize(JsonGenerator g, SerializationContext provider) throws JacksonException
      Description copied from class: BaseJsonNode
      Method called to serialize node instances using given generator.
      Specified by:
      serialize in interface JacksonSerializable
      Specified by:
      serialize in class BaseJsonNode
      Throws:
      JacksonException
    • equals

      public boolean equals(Object o)
      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.

      Specified by:
      equals in class JsonNode
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class BaseJsonNode