Class NBTypeConverter

java.lang.Object
io.nosqlbench.nb.api.config.standard.NBTypeConverter

public class NBTypeConverter extends 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 Details

    • CORE_TYPES

      public static Set<Class<?>> CORE_TYPES
      The 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, Class<O> outc)
    • tryConvert

      public static <T> Optional<T> tryConvert(Object input, Class<T> outType)
    • convertOr

      public static <T> T convertOr(Object input, T defaultValue)
    • convert

      public static <T> T convert(Object input, Class<T> outType)