Package jsonvalues
Class JsDouble
- java.lang.Object
-
- jsonvalues.JsDouble
-
- All Implemented Interfaces:
Comparable<JsDouble>,JsElem,JsNumber
public final class JsDouble extends Object implements JsNumber, Comparable<JsDouble>
Represents an immutable json number of type double.
-
-
Field Summary
Fields Modifier and Type Field Description doublexThe double value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<BigInteger>bigIntegerExact()Converts thisdoubleto aBigInteger, checking for lost information.intcompareTo(JsDouble o)Compares twoJsDoubleobjects numerically.booleanequals(@Nullable Object that)Indicates whether some other object is "equal to" this json double.booleanequals(JsBigDec jsBigDec)returns true if this double and the specified bigdecimal represent the same numberbooleanequals(JsBigInt jsBigInt)returns true if this double and the specified biginteger represent the same numberbooleanequals(JsInt jsInt)returns true if this double and the specified integer represent the same numberbooleanequals(JsLong jsLong)returns true if this double and the specified long represent the same numberinthashCode()Returns the hashcode of this json double.booleanisDouble()JsDoublemap(DoubleUnaryOperator fn)Maps this json double into another one.JsDoubleminus(JsDouble that)subtract this long from the specified onestatic JsDoubleof(double n)Static factory method to create a JsDouble from a double primitive type.JsDoubleplus(JsDouble that)adds up this long to the specified onebooleantest(DoublePredicate predicate)Tests the value of this json double on a predicate.JsDoubletimes(JsDouble 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, 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
-
-
-
-
Method Detail
-
compareTo
public int compareTo(JsDouble o)
Compares twoJsDoubleobjects numerically.- Specified by:
compareToin interfaceComparable<JsDouble>- See Also:
Double.compareTo(Double)
-
equals
public boolean equals(@Nullable Object that)
Indicates whether some other object is "equal to" this json double. Numbers of different types are equals if the have the same value.
-
hashCode
public int hashCode()
Returns the hashcode of this json double.
-
map
public JsDouble map(DoubleUnaryOperator fn)
Maps this json double into another one.- Parameters:
fn- the mapping function- Returns:
- a new JsDouble
-
minus
public JsDouble minus(JsDouble that)
subtract this long from the specified one- Parameters:
that- the specified long- Returns:
- this long minus the specified one
-
of
public static JsDouble of(double n)
Static factory method to create a JsDouble from a double primitive type.- Parameters:
n- the double primitive type- Returns:
- a new JsDouble
-
plus
public JsDouble plus(JsDouble that)
adds up this long to the specified one- Parameters:
that- the specified long- Returns:
- the sum of both longs
-
test
public boolean test(DoublePredicate predicate)
Tests the value of this json double on a predicate.- Parameters:
predicate- the predicate- Returns:
- true if this double satisfies the predicate
-
times
public JsDouble times(JsDouble that)
multiplies this long by the specified one- Parameters:
that- the specified long- Returns:
- this long times the specified one
-
toString
public String toString()
- Overrides:
toStringin classObject- Returns:
- a string representation of this object.
- See Also:
Double.toString
-
bigIntegerExact
public Optional<BigInteger> bigIntegerExact()
Converts thisdoubleto aBigInteger, checking for lost information. An empty optional is returned if thisdoublehas a nonzero fractional part.- Returns:
- this double as an bigint wrapped in an Optional
-
equals
public boolean equals(JsBigDec jsBigDec)
returns true if this double 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 double 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(JsLong jsLong)
returns true if this double 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(JsInt jsInt)
returns true if this double and the specified integer represent the same number- Parameters:
jsInt- the specified JsInt- Returns:
- true if both JsElem are the same value
-
-