This
- Self-reference to the subclass type itself.public abstract class SingleDecimal<This extends SingleDecimal<This>> extends Object implements SingleNumber<This>, Supplier<BigDecimal>
BigDecimal
.Modifier | Constructor and Description |
---|---|
protected |
SingleDecimal(BigDecimal rawValue,
Function<? super BigDecimal,? extends This> constructor) |
protected |
SingleDecimal(double rawValue,
Function<? super BigDecimal,? extends This> constructor) |
protected |
SingleDecimal(String rawValue,
Function<? super BigDecimal,? extends This> constructor) |
Modifier and Type | Method and Description |
---|---|
BigDecimal |
asNumber() |
int |
compareTo(This that) |
int |
compareToNumber(Number number) |
This |
divideBy(Number number) |
boolean |
equals(Object other) |
boolean |
equals(This that) |
Optional<This> |
filter(Predicate<? super BigDecimal> condition)
Test the raw value by
condition . |
This |
flatMap(Function<? super BigDecimal,? extends This> mapper)
Construct a new value of this type with the raw underlying value converted by
mapper . |
BigDecimal |
get() |
int |
hashCode() |
boolean |
is(Predicate<? super BigDecimal> condition)
Test the raw value with
condition . |
boolean |
isNegative() |
boolean |
isNot(Predicate<? super BigDecimal> condition)
Reverse of
is(Predicate) . |
boolean |
isPositive() |
boolean |
isZero() |
This |
map(Function<? super BigDecimal,? extends BigDecimal> mapper)
Construct a new value of this type with the raw underlying value converted by
mapper . |
This |
minus(Number number) |
This |
multiplyBy(Number number) |
This |
plus(Number number) |
BigDecimal |
raw()
Return the raw underlying value.
|
This |
round() |
This |
roundDown() |
This |
roundToPrecision(int decimals) |
This |
roundUp() |
String |
toString()
Override this method to provide custom
Object.toString() formatting. |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
$, $, $, divideBy, divideBy, format, format, isGreaterThan, isGreaterThan, isGreaterThanOrEqualTo, isGreaterThanOrEqualTo, isLessThan, isLessThan, isLessThanOrEqualTo, isLessThanOrEqualTo, isNonZero, minus, minus, multiplyBy, multiplyBy, plus, plus
isGreaterThan, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo, max, min
protected SingleDecimal(BigDecimal rawValue, Function<? super BigDecimal,? extends This> constructor)
rawValue
- The raw, immutable value this object will represent.constructor
- A method reference to the constructor of the implementing subclass.protected SingleDecimal(double rawValue, Function<? super BigDecimal,? extends This> constructor)
rawValue
- The raw, immutable value this object will represent.constructor
- A method reference to the constructor of the implementing subclass.protected SingleDecimal(String rawValue, Function<? super BigDecimal,? 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 BigDecimal raw()
public final BigDecimal get()
get
in interface Supplier<BigDecimal>
public String toString()
Object.toString()
formatting.
The default passes the call through to BigDecimal.toPlainString()
.public final BigDecimal asNumber()
asNumber
in interface SingleNumber<This extends SingleDecimal<This>>
public final int compareTo(This that)
compareTo
in interface Comparable<This extends SingleDecimal<This>>
public final int compareToNumber(Number number)
compareToNumber
in interface SingleNumber<This extends SingleDecimal<This>>
public final boolean isZero()
isZero
in interface SingleNumber<This extends SingleDecimal<This>>
public final boolean isPositive()
isPositive
in interface SingleNumber<This extends SingleDecimal<This>>
public final boolean isNegative()
isNegative
in interface SingleNumber<This extends SingleDecimal<This>>
public final This plus(Number number)
plus
in interface SingleNumber<This extends SingleDecimal<This>>
public final This minus(Number number)
minus
in interface SingleNumber<This extends SingleDecimal<This>>
public final This multiplyBy(Number number)
multiplyBy
in interface SingleNumber<This extends SingleDecimal<This>>
public final This divideBy(Number number)
divideBy
in interface SingleNumber<This extends SingleDecimal<This>>
public final This round()
public final This roundUp()
public final This roundDown()
public final This roundToPrecision(int decimals)
public final boolean equals(This that)
public final boolean is(Predicate<? super BigDecimal> 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(String::isEmpty))
public final boolean isNot(Predicate<? super BigDecimal> condition)
is(Predicate)
.public final Optional<This> filter(Predicate<? super BigDecimal> condition)
condition
.Optional
containing this instance if the condition is met; empty otherwise.is(Predicate)
public final This map(Function<? super BigDecimal,? extends BigDecimal> mapper)
mapper
.mapper
- The mapping function to apply to the raw underlying value.public final This flatMap(Function<? super BigDecimal,? extends This> mapper)
mapper
.mapper
- The mapping function to apply to the raw underlying value.mapper
.Copyright © 2022. All rights reserved.