This
- Self-reference to the subclass type itself.SingleComparable<This>
, SingleNumber<This>
, Comparable<This>
, Supplier<BigDecimal>
public abstract class SingleDecimal<This extends SingleDecimal<This>> extends Object implements SingleNumber<This>, Supplier<BigDecimal>
BigDecimal
.Modifier and Type | Field | Description |
---|---|---|
protected BigDecimal |
raw |
The raw underlying value.
|
Modifier | Constructor | Description |
---|---|---|
protected |
SingleDecimal(double rawValue,
Function<? super BigDecimal,? extends This> constructor) |
|
protected |
SingleDecimal(String rawValue,
Function<? super BigDecimal,? extends This> constructor) |
|
protected |
SingleDecimal(BigDecimal rawValue,
Function<? super BigDecimal,? extends This> constructor) |
Modifier and Type | Method | 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() |
|
This |
round() |
|
This |
roundDown() |
|
This |
roundToPrecision(int decimals) |
|
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 BigDecimal raw
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 BigDecimal get()
get
in interface Supplier<This extends SingleDecimal<This>>
public 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 boolean isZero()
isZero
in interface SingleNumber<This extends SingleDecimal<This>>
public boolean isPositive()
isPositive
in interface SingleNumber<This extends SingleDecimal<This>>
public 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 © 2020. All rights reserved.