public final class NumberTypes extends Object
NumberType utilities.| Modifier and Type | Method and Description |
|---|---|
static <T> @Nullable NumberType<T> |
from(@Nullable Class<T> clazz)
Returns, if applicable, the
NumberType instance from StandardNumberType and
MoreNumberTypes that corresponds to the provided class, null otherwise. |
static Stream<NumberType<?>> |
streamThroughAll()
Provides a stream of all
NumberType implementations provided by this library. |
static Number |
unwrapToStandardNumberType(Number number)
Unwraps the number to a basic number type, if applicable.
|
static @Nullable Number |
unwrapToStandardNumberType(@Nullable Object object)
Unwraps the object to a basic number type and returns the value if the given object is a
Number or
Character. |
@Nullable public static <T> @Nullable NumberType<T> from(@Nullable @Nullable Class<T> clazz)
NumberType instance from StandardNumberType and
MoreNumberTypes that corresponds to the provided class, null otherwise. Both primitive and
equivalent reference type are supported (e.g. int.class and Integer.class return
the same instance).
If you do not need the returned NumberType to produce values that exactly match the given class (i.e. if you
need the number type for range information and reading of values), you can use
unwrapToStandardNumberType(Number) to match more types.
T - the class's typeclazz - the class to processpublic static Stream<NumberType<?>> streamThroughAll()
NumberType implementations provided by this library.@Nullable public static @Nullable Number unwrapToStandardNumberType(@Nullable @Nullable Object object)
Number or
Character.
Specifically, this method converts Character to an int, and it unwraps the number types
AtomicInteger, AtomicLong, LongAccumulator, LongAdder, DoubleAccumulator
and DoubleAdder to their respective underlying type.
object - the object to unwrappublic static Number unwrapToStandardNumberType(Number number)
Specifically, this method unwraps the number types AtomicInteger, AtomicLong,
LongAccumulator, LongAdder, DoubleAccumulator and DoubleAdder to their respective
underlying type.
number - the object to unwrapCopyright © 2023. All rights reserved.