Package jsonvalues
Class JsLong
- java.lang.Object
-
- jsonvalues.JsLong
-
- All Implemented Interfaces:
Comparable<JsLong>,JsElem,JsNumber
public final class JsLong extends Object implements JsNumber, Comparable<JsLong>
Represents an immutable json number of type long.
-
-
Field Summary
Fields Modifier and Type Field Description longxThe long primitive.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(JsLong o)Compares twoJsLongobjects numerically.booleanequals(@Nullable Object that)Indicates whether some other object is "equal to" this json long.booleanequals(JsBigDec jsBigDec)returns true if this long and the specified bigdecimal represent the same numberbooleanequals(JsBigInt jsBigInt)returns true if this long and the specified biginteger represent the same numberbooleanequals(JsDouble jsDouble)returns true if this long and the specified double represent the same numberbooleanequals(JsInt jsInt)returns true if this long and the specified integer represent the same numberinthashCode()Returns the hashcode of this json long.OptionalIntintValueExact()Returns the value of this long; or an empty optional if the value overflows anint.booleanisLong()JsLongmap(LongUnaryOperator fn)Maps this json long into another one.JsLongminus(JsLong that)subtract this long from the specified onestatic JsLongof(long n)Static factory method to create a JsLong from a long primitive type.JsLongplus(JsLong that)adds up this long to the specified onebooleantest(LongPredicate predicate)Tests the value of this json long on a predicate.JsLongtimes(JsLong that)multiplies this long by the specified oneStringtoString()-
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, isArray, isBigDec, isBigDec, isBigInt, isBigInt, isBool, isDecimal, isDouble, isDouble, isFalse, isInstant, isInstant, isInt, isInt, isIntegral, isJson, isJson, isLocalDate, isLocalDate, isLocalDateTime, isLocalDateTime, isLong, isNothing, isNotJson, isNotNothing, isNotNull, isNotNumber, isNull, isObj, isObj, isSameType, isStr, isStr, isTrue
-
-
-
-
Method Detail
-
compareTo
public int compareTo(JsLong o)
Compares twoJsLongobjects numerically.- Specified by:
compareToin interfaceComparable<JsLong>- See Also:
Long.compareTo(Long)
-
equals
public boolean equals(@Nullable Object that)
Indicates whether some other object is "equal to" this json long. Numbers of different types are equals if the have the same value.
-
hashCode
public int hashCode()
Returns the hashcode of this json long.
-
map
public JsLong map(LongUnaryOperator fn)
Maps this json long into another one.- Parameters:
fn- the mapping function- Returns:
- a new JsLong
-
plus
public JsLong plus(JsLong that)
adds up this long to the specified one- Parameters:
that- the specified long- Returns:
- the sum of both longs
-
minus
public JsLong minus(JsLong that)
subtract this long from the specified one- Parameters:
that- the specified long- Returns:
- this long minus the specified one
-
times
public JsLong times(JsLong that)
multiplies this long by the specified one- Parameters:
that- the specified long- Returns:
- this long times the specified one
-
test
public boolean test(LongPredicate predicate)
Tests the value of this json long on a predicate.- Parameters:
predicate- the predicate- Returns:
- true if this long satisfies the predicate
-
toString
public String toString()
- Overrides:
toStringin classObject- Returns:
- a string representation of the long value.
- See Also:
Long.toString
-
of
public static JsLong of(long n)
Static factory method to create a JsLong from a long primitive type.- Parameters:
n- the long primitive type- Returns:
- a new JsLong
-
intValueExact
public OptionalInt intValueExact()
Returns the value of this long; or an empty optional if the value overflows anint.- Returns:
- this long as an int wrapped in an OptionalInt
-
equals
public boolean equals(JsBigDec jsBigDec)
returns true if this long 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(JsBigInt jsBigInt)
returns true if this long 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(JsInt jsInt)
returns true if this long 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(JsDouble jsDouble)
returns true if this long and the specified double represent the same number- Parameters:
jsDouble- the specified JsDouble- Returns:
- true if both JsElem are the same value
-
-