@Test void forClassOnClassWithNoDefaultConstructor() { Supplier<NoDefaultConstructor> noDefaultConstructorSupplier = Factory.forClass(NoDefaultConstructor.class); NoDefaultConstructor noDefaultConstructor = noDefaultConstructorSupplier.get(); assertThat(noDefaultConstructor, notNullValue()); assertThat(noDefaultConstructor, instanceOf(NoDefaultConstructor.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);  }