Functions { public static <R> R invoke(final Function<R> f, final List<Object> args) { return buildInvocation(f, args).apply(); }  static R invoke(final Function<R> f, final List<Object> args); @SuppressWarnings("unchecked") static Function0<R> buildInvocation(final Function<R> f, final List<Object> args); static Function0<R> identify(final Function0<R> f, final String identity); static Function1<T, R> identify(final Function1<T, R> f,
      final String identity); static Function2<T1, T2, R> identify(final Function2<T1, T2, R> f,
      final String identity); static Function3<T1, T2, T3, R> identify(final Function3<T1, T2, T3, R> f,
      final String identity); static Function4<T1, T2, T3, T4, R> identify(
      final Function4<T1, T2, T3, T4, R> f, final String identity); static Function5<T1, T2, T3, T4, T5, R> identify(
      final Function5<T1, T2, T3, T4, T5, R> f, final String identity); static Function0<V> compose(final Function0<R> first,
      final Function1<? super R, ? extends V> second); static Function1<T, V> compose(final Function1<? super T, ? extends R> first,
      final Function1<? super R, ? extends V> second); static Function2<T1, T2, V> compose(
      final Function2<? super T1, ? super T2, ? extends R> first,
      final Function1<? super R, ? extends V> second); static Function3<T1, T2, T3, V> compose(
      final Function3<? super T1, ? super T2, ? super T3, ? extends R> first,
      final Function1<? super R, ? extends V> second); static Function4<T1, T2, T3, T4, V> compose(
      final Function4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> first,
      final Function1<? super R, ? extends V> second); static Function5<T1, T2, T3, T4, T5, V> compose(
      final Function5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R>
          first, final Function1<? super R, ? extends V> second);  }
@Test public void testInvoke() { final int[] expected = { randomUUID().hashCode(), randomUUID().hashCode(), randomUUID().hashCode(), randomUUID().hashCode(), randomUUID().hashCode(), randomUUID().hashCode(), }; final Function<?>[] functions = { new Function0<Object>() { @Override public Object apply() { return expected[0]; } }, new Function1<Object, Object>() { @Override public Object apply(Object t1) { return expected[1]; } }, new Function2<Object, Object, Object>() { @Override public Object apply(Object t1, Object t2) { return expected[2]; } }, new Function3<Object, Object, Object, Object>() { @Override public Object apply(Object t1, Object t2, Object t3) { return expected[3]; } }, new Function4<Object, Object, Object, Object, Object>() { @Override public Object apply(Object t1, Object t2, Object t3, Object t4) { return expected[4]; } }, new Function5<Object, Object, Object, Object, Object, Object>() { @Override public Object apply(Object t1, Object t2, Object t3, Object t4, Object t5) { return expected[5]; } }, }; for (int i = 0; i < functions.length; ++i) { final Function<?> f = functions[i]; final Object[] args = new Object[i]; final Object actual = Functions.invoke(f, asList(args)); assertEquals(expected[i], actual); } }