@Test(expected = NullPointerException.class) public void shouldThrowNullPointerExceptionIfNullUnaryFunctionSuppliedToUncheckedInstantiate() throws Exception { Class<String> classToInstantiate = String.class; UnaryFunction<? super Exception, ? extends RuntimeException> function = null; Classes.uncheckedInstantiate(classToInstantiate, function); }
public static <T> T uncheckedInstantiate(final Class<T> classToInstantiate) { return uncheckedInstantiate(classToInstantiate, new UnaryFunction<Exception, RuntimeException>() { @Override public RuntimeException call(Exception exception) { throw new IllegalArgumentException( format("Could not instantiate instance of type %s. Does it have a public no argument constructor?", classToInstantiate.getSimpleName()), exception); } }); }
Classes { public static <T> T uncheckedInstantiate(final Class<T> classToInstantiate) { return uncheckedInstantiate(classToInstantiate, new UnaryFunction<Exception, RuntimeException>() { @Override public RuntimeException call(Exception exception) { throw new IllegalArgumentException( format("Could not instantiate instance of type %s. Does it have a public no argument constructor?", classToInstantiate.getSimpleName()), exception); } }); } }
Classes { public static <T> T uncheckedInstantiate(final Class<T> classToInstantiate) { return uncheckedInstantiate(classToInstantiate, new UnaryFunction<Exception, RuntimeException>() { @Override public RuntimeException call(Exception exception) { throw new IllegalArgumentException( format("Could not instantiate instance of type %s. Does it have a public no argument constructor?", classToInstantiate.getSimpleName()), exception); } }); }  }
Classes { public static <T> T uncheckedInstantiate(final Class<T> classToInstantiate) { return uncheckedInstantiate(classToInstantiate, new UnaryFunction<Exception, RuntimeException>() { @Override public RuntimeException call(Exception exception) { throw new IllegalArgumentException( format("Could not instantiate instance of type %s. Does it have a public no argument constructor?", classToInstantiate.getSimpleName()), exception); } }); }  static T uncheckedInstantiate(final Class<T> classToInstantiate); static T uncheckedInstantiate(
            Class<T> classToInstantiate,
            final RuntimeException exception); static T uncheckedInstantiate(
            Class<T> classToInstantiate,
            UnaryFunction<? super Exception, ? extends RuntimeException> exceptionHandler); }
Classes { public static <T> T uncheckedInstantiate(final Class<T> classToInstantiate) { return uncheckedInstantiate(classToInstantiate, new UnaryFunction<Exception, RuntimeException>() { @Override public RuntimeException call(Exception exception) { throw new IllegalArgumentException( format("Could not instantiate instance of type %s. Does it have a public no argument constructor?", classToInstantiate.getSimpleName()), exception); } }); }  static T uncheckedInstantiate(final Class<T> classToInstantiate); static T uncheckedInstantiate(
            Class<T> classToInstantiate,
            final RuntimeException exception); static T uncheckedInstantiate(
            Class<T> classToInstantiate,
            UnaryFunction<? super Exception, ? extends RuntimeException> exceptionHandler);  }