Package jsonvalues
Class JsInt
- java.lang.Object
-
- jsonvalues.JsInt
-
- All Implemented Interfaces:
Comparable<JsInt>
,JsElem
,JsNumber
public final class JsInt extends Object implements JsNumber, Comparable<JsInt>
Represents an immutable json number of type integer.
-
-
Field Summary
Fields Modifier and Type Field Description int
x
The integer value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(JsInt o)
Compares twoJsInt
objects numerically.boolean
equals(@Nullable Object that)
Indicates whether some other object is "equal to" this json integer.boolean
equals(JsBigDec jsBigDec)
returns true if this integer and the specified bigdecimal represent the same numberboolean
equals(JsBigInt jsBigInt)
returns true if this integer and the specified biginteger represent the same numberboolean
equals(JsDouble jsDouble)
returns true if this integer and the specified double represent the same numberboolean
equals(JsLong jsLong)
returns true if this integer and the specified long represent the same numberint
hashCode()
Returns the hashcode of this json integer.boolean
isBigDec()
boolean
isBigInt()
boolean
isDouble()
boolean
isInt()
boolean
isLong()
JsInt
map(IntUnaryOperator fn)
Maps this json integer into another one.JsInt
minus(JsInt that)
subtract this integer from the specified onestatic JsInt
of(int n)
Static factory method to create a JsInt from an integer primitive type.JsInt
plus(JsInt that)
adds up this integer to the specified oneboolean
test(IntPredicate predicate)
Tests the value of this json integer on a predicate.JsInt
times(JsInt that)
multiplies this integer by the specified oneString
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
-
-
-
-
Method Detail
-
compareTo
public int compareTo(JsInt o)
Compares twoJsInt
objects numerically.- Specified by:
compareTo
in interfaceComparable<JsInt>
- See Also:
Integer.compareTo(Integer)
-
equals
public boolean equals(@Nullable Object that)
Indicates whether some other object is "equal to" this json integer. Numbers of different types are equals if the have the same value.
-
hashCode
public int hashCode()
Returns the hashcode of this json integer.
-
toString
public String toString()
- Overrides:
toString
in classObject
- Returns:
- a string representation of the integer value.
- See Also:
Integer.toString
-
of
public static JsInt of(int n)
Static factory method to create a JsInt from an integer primitive type.- Parameters:
n
- the integer primitive type- Returns:
- a new JsInt
-
map
public JsInt map(IntUnaryOperator fn)
Maps this json integer into another one.- Parameters:
fn
- the mapping function- Returns:
- a new JsInt
-
plus
public JsInt plus(JsInt that)
adds up this integer to the specified one- Parameters:
that
- the specified integer- Returns:
- the sum of both integers
-
minus
public JsInt minus(JsInt that)
subtract this integer from the specified one- Parameters:
that
- the specified integer- Returns:
- this integer minus the specified one
-
times
public JsInt times(JsInt that)
multiplies this integer by the specified one- Parameters:
that
- the specified integer- Returns:
- this integer times the specified one
-
test
public boolean test(IntPredicate predicate)
Tests the value of this json integer on a predicate.- Parameters:
predicate
- the predicate- Returns:
- true if this integer satisfies the predicate
-
equals
public boolean equals(JsBigInt jsBigInt)
returns true if this integer and the specified biginteger represent the same number- Parameters:
jsBigInt
- the specified JsBigInt- Returns:
- true if both JsElem are the same value
-
equals
public boolean equals(JsBigDec jsBigDec)
returns true if this integer 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(JsLong jsLong)
returns true if this integer 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 integer 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()
-
-