Package jsonvalues
Class JsBigInt
- java.lang.Object
-
- jsonvalues.JsBigInt
-
- All Implemented Interfaces:
Comparable<JsBigInt>
,JsElem
,JsNumber
public final class JsBigInt extends Object implements JsNumber, Comparable<JsBigInt>
Represents an immutable json number of type BigInteger.
-
-
Field Summary
Fields Modifier and Type Field Description BigInteger
x
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.OptionalInt
intValueExact()
Returns the value of this biginteger; or an empty optional if the value overflows anint
.boolean
isBigDec()
boolean
isBigInt()
boolean
isDouble()
boolean
isInt()
boolean
isLong()
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.JsElem
asJsArray, asJsBigDec, asJsBigInt, asJsBool, asJsDouble, asJsInt, asJsLong, asJsObj, asJson, asJsStr, isArray, isBigDec, isBigInt, isDecimal, isDouble, isInstant, isInstant, isInt, isIntegral, isJson, isJson, isLocalDate, isLocalDate, isLocalDateTime, isLocalDateTime, isLong, isNotJson, isNotNothing, isNotNull, isNotNumber, isObj, isSameType, isStr
-
-
-
-
Field Detail
-
x
public final BigInteger x
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
-
isInt
public boolean isInt()
-
isDouble
public boolean isDouble()
-
isBigDec
public boolean isBigDec()
-
isLong
public boolean isLong()
-
-