Class NBTypeConverter
java.lang.Object
io.nosqlbench.nb.api.config.standard.NBTypeConverter
public class NBTypeConverter
extends java.lang.Object
Shenanigans in the java type system, particularly those around boxing,
generics, type-erasure and primitive conversions have brought us here
in our attempt to simplify things.
In the future, when Java has fewer special cases in the type system,
this class can be removed.
General purpose strategies for conversion
can be injected into the
do_convert(Object, Class) and
canConvert(Object, Class)
methods.-
Field Summary
Fields Modifier and Type Field Description static java.util.Set<java.lang.Class<?>>CORE_TYPESThe core types should have full set closure on conversions are not narrowing -
Constructor Summary
Constructors Constructor Description NBTypeConverter() -
Method Summary
Modifier and Type Method Description static <I, O> booleancanConvert(I input, java.lang.Class<O> outc)static <T> Tconvert(java.lang.Object input, java.lang.Class<T> outType)static <T> TconvertOr(java.lang.Object input, T defaultValue)static <T> java.util.Optional<T>tryConvert(java.lang.Object input, java.lang.Class<T> outType)
-
Field Details
-
CORE_TYPES
public static java.util.Set<java.lang.Class<?>> CORE_TYPESThe core types should have full set closure on conversions are not narrowing
-
-
Constructor Details
-
NBTypeConverter
public NBTypeConverter()
-
-
Method Details
-
canConvert
public static <I, O> boolean canConvert(I input, java.lang.Class<O> outc) -
tryConvert
public static <T> java.util.Optional<T> tryConvert(java.lang.Object input, java.lang.Class<T> outType) -
convertOr
public static <T> T convertOr(java.lang.Object input, T defaultValue) -
convert
public static <T> T convert(java.lang.Object input, java.lang.Class<T> outType)
-