T - number type this range describespublic interface ValueRange<T>
| Modifier and Type | Method and Description |
|---|---|
T |
getMaxInOwnType() |
@Nullable BigDecimal |
getMaxValue() |
T |
getMinInOwnType() |
@Nullable BigDecimal |
getMinValue() |
boolean |
hasInfinityAndNaN()
Returns whether the type has values for
NaN and infinity, such as Double
with Double.POSITIVE_INFINITY. |
default boolean |
isEqualOrSupersetOf(ValueRange<?> other)
Returns whether this value range is equal or larger than the given value range.
|
default boolean |
supportsAllValuesOf(ValueRange<?> other)
Specifies whether
this range can represent all values of the given value range without loss of
magnitude. |
boolean |
supportsDecimals() |
@Nullable @Nullable BigDecimal getMinValue()
@Nullable @Nullable BigDecimal getMaxValue()
@Nullable T getMinInOwnType()
@Nullable T getMaxInOwnType()
boolean supportsDecimals()
boolean hasInfinityAndNaN()
NaN and infinity, such as Double
with Double.POSITIVE_INFINITY.default boolean supportsAllValuesOf(ValueRange<?> other)
this range can represent all values of the given value range without loss of
magnitude. Loss of precision is not considered. Support for decimals is ignored
by this method as it does not constitute a loss of magnitude. For example,
BIG_INTEGER.supportsAllValuesOf(BIG_DECIMAL) returns true.
In contrast to isEqualOrSupersetOf(ch.jalu.typeresolver.numbers.ValueRange<?>), this method specifies whether every possible value of
the other range can be represented by this range, including infinity and NaN. Therefore,
BIG_INTEGER.getValueRange().supportsAllValuesOf(DOUBLE.getValueRange() evaluates to false
(because BigInteger cannot represent infinity or NaN), while comparing the same ranges with
isEqualOrSupersetOf(ch.jalu.typeresolver.numbers.ValueRange<?>) evaluates to true.
Developers comparing two number types can use NumberType.supportsAllValuesOf(NumberType) as a shortcut
to this method.
other - the number type to checkdefault boolean isEqualOrSupersetOf(ValueRange<?> other)
other range fit into this range. The comparison is based on the
minimum and maximum values of the ranges. The presence or absence of decimals or the ability to represent special
values like Double.NaN is not taken into account.
Use supportsAllValuesOf(ch.jalu.typeresolver.numbers.ValueRange<?>) if you want to specifically check that every value (such as NaN) of a
type can be represented.
other - the other range to compare withCopyright © 2023. All rights reserved.