Functionals { public static <A,B,C> Function<A,C> chain(final Function<A,? extends B> f1, final Function<B,C> f2) { return Functions.compose(f2, f1); }  static Function<A,C> chain(final Function<A,? extends B> f1, final Function<B,C> f2); static Function<A,D> chain(final Function<A,? extends B> f1, final Function<B,? extends C> f2, final Function<C,D> f3); static Function<A,E> chain(final Function<A,? extends B> f1, final Function<B,? extends C> f2, final Function<C,? extends D> f3, final Function<D,E> f4); static IfFunctionBuilderApplyingFirst<I> ifEquals(I test); static IfFunctionBuilderApplyingFirst<I> ifNotEquals(I test); static IfFunctionBuilderApplyingFirst<I> ifPredicate(Predicate<I> test); static Function<I,O> function(final Supplier<O> supplier); static Function<I,Void> function(final Runnable runnable); static Runnable runnable(final Supplier<?> supplier); static Callable<T> callable(final Supplier<T> supplier); static Callable<U> callable(Function<T,U> f, T x); static Predicate<T> predicate(final Function<T,Boolean> f); static Callable<Boolean> isSatisfied(final T subject, final Predicate<T> predicate);  }
@Test public void testChain() { Assert.assertEquals(Functionals.chain(MathFunctions.plus(1), MathFunctions.times(2)).apply(3), (Integer)8); Assert.assertEquals(Functionals.chain(MathFunctions.times(2), MathFunctions.plus(1)).apply(3), (Integer)7); }