Package jsonvalues
Class JsBigInt
- java.lang.Object
-
- jsonvalues.JsBigInt
-
- All Implemented Interfaces:
Comparable<JsBigInt>
,JsValue
public final class JsBigInt extends Object implements Comparable<JsBigInt>
Represents an immutable json number of type BigInteger.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ID
BigInteger
value
the big integer value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(JsBigInt o)
Compares twoJsBigInt
objects numerically.boolean
equals(@Nullable Object that)
Indicates whether some other object is "equal to" this json big integer.boolean
equals(JsBigDec jsBigDec)
returns true if this bigint and the specified bigdecimal represent the same numberboolean
equals(JsDouble jsDouble)
returns true if this bigint and the specified double represent the same numberboolean
equals(JsInt jsInt)
returns true if this biginteger and the specified integer represent the same numberboolean
equals(JsLong jsLong)
returns true if this bigint and the specified long represent the same numberint
hashCode()
Returns the hashcode of this json big integer.int
id()
OptionalInt
intValueExact()
Returns the value of this biginteger; or an empty optional if the value overflows anint
.boolean
isBigInt()
boolean
isNumber()
OptionalLong
longValueExact()
Returns the value of this biginteger; or an empty optional if the value overflows anlong
.JsBigInt
map(UnaryOperator<BigInteger> fn)
Maps this json bigint into another one.static JsBigInt
of(BigInteger n)
Static factory method to create a JsBigInt from BigInteger objects.boolean
test(Predicate<BigInteger> predicate)
Tests the value of this json bigint on a predicate.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jsonvalues.JsValue
isArray, isArray, isBigDec, isBigDec, isBigInt, isBool, isDecimal, isDouble, isDouble, isFalse, isInstant, isInstant, isInt, isInt, isIntegral, isJson, isJson, isLocalDate, isLocalDate, isLocalDateTime, isLocalDateTime, isLong, isLong, isNothing, isNotJson, isNotNothing, isNotNull, isNotNumber, isNull, isObj, isObj, isSameType, isStr, isStr, isTrue, toJsArray, toJsBigDec, toJsBigInt, toJsBool, toJsDouble, toJsInt, toJsLong, toJsObj, toJson, toJsStr
-
-
-
-
Field Detail
-
ID
public static final int ID
- See Also:
- Constant Field Values
-
value
public final BigInteger value
the big integer value.
-
-
Method Detail
-
compareTo
public int compareTo(JsBigInt o)
Compares twoJsBigInt
objects numerically.- Specified by:
compareTo
in interfaceComparable<JsBigInt>
- See Also:
compareTo(JsBigInt)
-
equals
public boolean equals(@Nullable Object that)
Indicates whether some other object is "equal to" this json big integer. Numbers of different types are equals if the have the same value.
-
hashCode
public int hashCode()
Returns the hashcode of this json big integer.
-
map
public JsBigInt map(UnaryOperator<BigInteger> fn)
Maps this json bigint into another one.- Parameters:
fn
- the mapping function- Returns:
- a new JsBigInt
-
test
public boolean test(Predicate<BigInteger> predicate)
Tests the value of this json bigint on a predicate.- Parameters:
predicate
- the predicate- Returns:
- true if this big integer satisfies the predicate
-
of
public static JsBigInt of(BigInteger n)
Static factory method to create a JsBigInt from BigInteger objects.- Parameters:
n
- the big integer- Returns:
- a new JsBigInt
-
toString
public String toString()
- Overrides:
toString
in classObject
- Returns:
- a string representation of the bigint value.
- See Also:
BigInteger.toString
-
intValueExact
public OptionalInt intValueExact()
Returns the value of this biginteger; or an empty optional if the value overflows anint
.- Returns:
- this biginteger as an int wrapped in an OptionalInt
-
longValueExact
public OptionalLong longValueExact()
Returns the value of this biginteger; or an empty optional if the value overflows anlong
.- Returns:
- this biginteger as an long wrapped in an OptionalLong
-
equals
public boolean equals(JsBigDec jsBigDec)
returns true if this bigint and the specified bigdecimal represent the same number- Parameters:
jsBigDec
- the specified JsBigDec- Returns:
- true if both JsElem are the same value
-
equals
public boolean equals(JsInt jsInt)
returns true if this biginteger and the specified integer represent the same number- Parameters:
jsInt
- the specified JsInt- Returns:
- true if both JsElem are the same value
-
equals
public boolean equals(JsLong jsLong)
returns true if this bigint and the specified long represent the same number- Parameters:
jsLong
- the specified JsLong- Returns:
- true if both JsElem are the same value
-
equals
public boolean equals(JsDouble jsDouble)
returns true if this bigint and the specified double represent the same number- Parameters:
jsDouble
- the specified JsDouble- Returns:
- true if both JsElem are the same value
-
isBigInt
public boolean isBigInt()
-
-