@Test void forClassOnClassWithDefaultConstructor() { Supplier<ClassWithMultipleConstructors> factory = Factory.forClass(ClassWithMultipleConstructors.class); ClassWithMultipleConstructors result = factory.get(); assertThat(result, notNullValue()); assertThat(result.intValue(), is(501)); }
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);  }