This
- Self-reference to the subclass type itself.SingleComparable<This>
, SingleNumber<This>
, Comparable<This>
, DoubleSupplier
public abstract class SingleDouble<This extends SingleDouble<This>> extends Object implements SingleNumber<This>, DoubleSupplier
Single
.Modifier and Type | Field | Description |
---|---|---|
protected double |
raw |
The raw underlying value.
|
Modifier | Constructor | Description |
---|---|---|
protected |
SingleDouble(double rawValue,
DoubleFunction<? extends This> constructor) |
Modifier and Type | Method | Description |
---|---|---|
Double |
asNumber() |
|
int |
compareTo(This that) |
|
int |
compareToNumber(double number) |
|
int |
compareToNumber(Number number) |
|
This |
divideBy(double number) |
|
This |
divideBy(Number number) |
|
This |
divideBy(DoubleSupplier number) |
|
boolean |
equals(Object other) |
|
boolean |
equals(This that) |
|
Optional<This> |
filter(DoublePredicate condition) |
Test the raw value by
condition . |
This |
flatMap(DoubleFunction<? extends This> mapper) |
Construct a new value of this type with the raw underlying value converted by
mapper . |
double |
getAsDouble() |
|
int |
hashCode() |
|
boolean |
is(DoublePredicate condition) |
Test the raw value with
condition . |
boolean |
isGreaterThan(DoubleSupplier number) |
|
boolean |
isGreaterThanOrEqualTo(DoubleSupplier number) |
|
boolean |
isLessThan(DoubleSupplier number) |
|
boolean |
isLessThanOrEqualTo(DoubleSupplier number) |
|
boolean |
isNegative() |
|
boolean |
isNot(DoublePredicate condition) |
Reverse of
is(DoublePredicate) . |
boolean |
isPositive() |
|
boolean |
isZero() |
|
This |
map(DoubleUnaryOperator mapper) |
Construct a new value of this type with the raw underlying value converted by
mapper . |
This |
minus(double number) |
|
This |
minus(Number number) |
|
This |
minus(DoubleSupplier number) |
|
This |
multiplyBy(double number) |
|
This |
multiplyBy(Number number) |
|
This |
multiplyBy(DoubleSupplier number) |
|
This |
plus(double number) |
|
This |
plus(Number number) |
|
This |
plus(DoubleSupplier number) |
|
double |
raw() |
Return the raw underlying value.
|
This |
round() |
|
This |
roundDown() |
|
This |
roundUp() |
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isGreaterThan, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo, max, min
divideBy, divideBy, format, format, isGreaterThan, isGreaterThan, isGreaterThanOrEqualTo, isGreaterThanOrEqualTo, isLessThan, isLessThan, isLessThanOrEqualTo, isLessThanOrEqualTo, isNonZero, minus, minus, multiplyBy, multiplyBy, plus, plus
protected final double raw
protected SingleDouble(double rawValue, DoubleFunction<? extends This> constructor)
rawValue
- The raw, immutable value this object will represent.constructor
- A method reference to the constructor of the implementing subclass.public final double raw()
public double getAsDouble()
getAsDouble
in interface DoubleSupplier
public final boolean equals(This that)
public Double asNumber()
asNumber
in interface SingleNumber<This extends SingleDouble<This>>
public final int compareTo(This that)
compareTo
in interface Comparable<This extends SingleDouble<This>>
public final int compareToNumber(Number number)
compareToNumber
in interface SingleNumber<This extends SingleDouble<This>>
public final int compareToNumber(double number)
public boolean isZero()
isZero
in interface SingleNumber<This extends SingleDouble<This>>
public boolean isPositive()
isPositive
in interface SingleNumber<This extends SingleDouble<This>>
public boolean isNegative()
isNegative
in interface SingleNumber<This extends SingleDouble<This>>
public final This plus(Number number)
plus
in interface SingleNumber<This extends SingleDouble<This>>
public final This minus(Number number)
minus
in interface SingleNumber<This extends SingleDouble<This>>
public final This multiplyBy(Number number)
multiplyBy
in interface SingleNumber<This extends SingleDouble<This>>
public final This divideBy(Number number)
divideBy
in interface SingleNumber<This extends SingleDouble<This>>
public final This plus(double number)
public final This minus(double number)
public final This multiplyBy(double number)
public final This divideBy(double number)
public final This plus(DoubleSupplier number)
public final This minus(DoubleSupplier number)
public final This multiplyBy(DoubleSupplier number)
public final This divideBy(DoubleSupplier number)
public final boolean isGreaterThan(DoubleSupplier number)
public final boolean isGreaterThanOrEqualTo(DoubleSupplier number)
public final boolean isLessThan(DoubleSupplier number)
public final boolean isLessThanOrEqualTo(DoubleSupplier number)
public final This round()
public final This roundUp()
public final This roundDown()
public final boolean is(DoublePredicate condition)
condition
.
This method is useful when using Optional.filter(java.util.function.Predicate<? super T>)
or Stream.filter(java.util.function.Predicate<? super T>)
.
optional.filter(x -> x.is($ -> $ > 0))
public final boolean isNot(DoublePredicate condition)
is(DoublePredicate)
.public final Optional<This> filter(DoublePredicate condition)
condition
.Optional
containing this instance if the condition is met; empty otherwise.is(DoublePredicate)
public final This map(DoubleUnaryOperator mapper)
mapper
.mapper
- The mapping function to apply to the raw underlying value.public final This flatMap(DoubleFunction<? extends This> mapper)
mapper
.mapper
- The mapping function to apply to the raw underlying value.mapper
.Copyright © 2020. All rights reserved.