Package jsonvalues
Class JsDouble
- java.lang.Object
-
- jsonvalues.JsDouble
-
- All Implemented Interfaces:
Comparable<JsDouble>
,JsElem
public final class JsDouble extends Object implements Comparable<JsDouble>
Represents an immutable json number of type double.
-
-
Field Summary
Fields Modifier and Type Field Description double
x
The double value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<BigInteger>
bigIntegerExact()
Converts thisdouble
to aBigInteger
, checking for lost information.int
compareTo(JsDouble o)
Compares twoJsDouble
objects numerically.boolean
equals(@Nullable Object that)
Indicates whether some other object is "equal to" this json double.boolean
equals(JsBigDec jsBigDec)
returns true if this double and the specified bigdecimal represent the same numberboolean
equals(JsBigInt jsBigInt)
returns true if this double and the specified biginteger represent the same numberboolean
equals(JsInt jsInt)
returns true if this double and the specified integer represent the same numberboolean
equals(JsLong jsLong)
returns true if this double and the specified long represent the same numberint
hashCode()
Returns the hashcode of this json double.boolean
isDouble()
boolean
isNumber()
JsDouble
map(DoubleUnaryOperator fn)
Maps this json double into another one.JsDouble
minus(JsDouble that)
subtract this long from the specified onestatic JsDouble
of(double n)
Static factory method to create a JsDouble from a double primitive type.JsDouble
plus(JsDouble that)
adds up this long to the specified oneboolean
test(DoublePredicate predicate)
Tests the value of this json double on a predicate.JsDouble
times(JsDouble that)
multiplies this long 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, 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 twoJsDouble
objects numerically.- Specified by:
compareTo
in 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:
toString
in classObject
- Returns:
- a string representation of this object.
- See Also:
Double.toString
-
bigIntegerExact
public Optional<BigInteger> bigIntegerExact()
Converts thisdouble
to aBigInteger
, checking for lost information. An empty optional is returned if thisdouble
has 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
-
isDouble
public boolean isDouble()
-
-