@Test public void intConstructorParamWorks() { int test = 2; class Holder { int result; } final Holder holder = new Holder(); class Instantiated { @SuppressWarnings("unused") Instantiated(int param) { holder.result = param; } } FunkyFunction<Instantiated> executor = new FunkyFunction<Instantiated>(Instantiated.class, this, test, holder); executor.execute(); assertSame(test, holder.result); }
public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof Error) { throw ((Error) cause); } else { throw ((RuntimeException) cause); } } catch (Exception e) { throw new IllegalStateException("This should never happen. Due to previously checked constraints (see extractConstructor()), no exception may actually be caught here.", e); } }
FunkyFunction implements ClassFunction<T> { public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof Error) { throw ((Error) cause); } else { throw ((RuntimeException) cause); } } catch (Exception e) { throw new IllegalStateException("This should never happen. Due to previously checked constraints (see extractConstructor()), no exception may actually be caught here.", e); } } }
FunkyFunction implements ClassFunction<T> { public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof Error) { throw ((Error) cause); } else { throw ((RuntimeException) cause); } } catch (Exception e) { throw new IllegalStateException("This should never happen. Due to previously checked constraints (see extractConstructor()), no exception may actually be caught here.", e); } } FunkyFunction(Class<T> applyingClass, Object... constructorArguments); }
FunkyFunction implements ClassFunction<T> { public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof Error) { throw ((Error) cause); } else { throw ((RuntimeException) cause); } } catch (Exception e) { throw new IllegalStateException("This should never happen. Due to previously checked constraints (see extractConstructor()), no exception may actually be caught here.", e); } } FunkyFunction(Class<T> applyingClass, Object... constructorArguments); T execute(); @Override String getClassSimpleName(); }
FunkyFunction implements ClassFunction<T> { public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof Error) { throw ((Error) cause); } else { throw ((RuntimeException) cause); } } catch (Exception e) { throw new IllegalStateException("This should never happen. Due to previously checked constraints (see extractConstructor()), no exception may actually be caught here.", e); } } FunkyFunction(Class<T> applyingClass, Object... constructorArguments); T execute(); @Override String getClassSimpleName();  }