@Test void cannotInstantiate() { calling(() -> Factory.forClass(Factory.class).get()) .shouldThrow(RuntimeException.class) .withMessage(is("java.lang.reflect.InvocationTargetException")) .withCause(InvocationTargetException.class) .withCause(RuntimeInstantiationException.class); }
public static <T> Supplier<T> forClass(Class<T> aClass) { return ClassUtil.constructor(aClass) .map(Factory::invoke) .orElseGet(() -> () -> ObjenesisHelper.newInstance(aClass)); }
Factory extends UtilityClass { public static <T> Supplier<T> forClass(Class<T> aClass) { return ClassUtil.constructor(aClass) .map(Factory::invoke) .orElseGet(() -> () -> ObjenesisHelper.newInstance(aClass)); } }
Factory extends UtilityClass { public static <T> Supplier<T> forClass(Class<T> aClass) { return ClassUtil.constructor(aClass) .map(Factory::invoke) .orElseGet(() -> () -> ObjenesisHelper.newInstance(aClass)); }  }
Factory extends UtilityClass { public static <T> Supplier<T> forClass(Class<T> aClass) { return ClassUtil.constructor(aClass) .map(Factory::invoke) .orElseGet(() -> () -> ObjenesisHelper.newInstance(aClass)); }  static Supplier<T> forClass(Class<T> aClass); @SuppressWarnings("unchecked") static Supplier<T> forType(TypeToken<T> aClass); }
Factory extends UtilityClass { public static <T> Supplier<T> forClass(Class<T> aClass) { return ClassUtil.constructor(aClass) .map(Factory::invoke) .orElseGet(() -> () -> ObjenesisHelper.newInstance(aClass)); }  static Supplier<T> forClass(Class<T> aClass); @SuppressWarnings("unchecked") static Supplier<T> forType(TypeToken<T> aClass);  }