@Test public void composesSevenUnaryFunctions() { UnaryFunction<String, BigDecimal> first = fromStringToBigDecimal(); UnaryFunction<BigDecimal, Long> second = fromBigDecimalToLong(); UnaryFunction<Long, Integer> third = fromLongToInteger(); UnaryFunction<Integer, Double> fourth = fromIntegerToDouble(); UnaryFunction<Double, Float> fifth = fromDoubleToFloat(); UnaryFunction<Float, BigInteger> sixth = fromFloatToBigInteger(); UnaryFunction<BigInteger, BigInteger> seventh = toDoubledBigInteger(); UnaryFunction<String, BigInteger> chained = UnaryFunctions.compose( first, second, third, fourth, fifth, sixth, seventh); BigInteger result = chained.call("1234"); assertThat(result, is(new BigInteger("2468"))); }
public static <Q, R, S> UnaryFunction<Q, S> compose( final UnaryFunction<? super Q, ? extends R> first, final UnaryFunction<? super R, ? extends S> second) { return new UnaryFunction<Q, S>() { @Override public S call(Q input) { return second.call(first.call(input)); } }; }
UnaryFunctions { public static <Q, R, S> UnaryFunction<Q, S> compose( final UnaryFunction<? super Q, ? extends R> first, final UnaryFunction<? super R, ? extends S> second) { return new UnaryFunction<Q, S>() { @Override public S call(Q input) { return second.call(first.call(input)); } }; } }
UnaryFunctions { public static <Q, R, S> UnaryFunction<Q, S> compose( final UnaryFunction<? super Q, ? extends R> first, final UnaryFunction<? super R, ? extends S> second) { return new UnaryFunction<Q, S>() { @Override public S call(Q input) { return second.call(first.call(input)); } }; } private  UnaryFunctions(); }
UnaryFunctions { public static <Q, R, S> UnaryFunction<Q, S> compose( final UnaryFunction<? super Q, ? extends R> first, final UnaryFunction<? super R, ? extends S> second) { return new UnaryFunction<Q, S>() { @Override public S call(Q input) { return second.call(first.call(input)); } }; } private  UnaryFunctions(); static UnaryFunction<T, T> identity(); static UnaryFunction<Q, S> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second); static UnaryFunction<Q, T> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third); static UnaryFunction<Q, U> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third,
            final UnaryFunction<? super T, ? extends U> fourth); static UnaryFunction<Q, V> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third,
            final UnaryFunction<? super T, ? extends U> fourth,
            final UnaryFunction<? super U, ? extends V> fifth); static UnaryFunction<Q, W> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third,
            final UnaryFunction<? super T, ? extends U> fourth,
            final UnaryFunction<? super U, ? extends V> fifth,
            final UnaryFunction<? super V, ? extends W> sixth); static UnaryFunction<Q, X> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third,
            final UnaryFunction<? super T, ? extends U> fourth,
            final UnaryFunction<? super U, ? extends V> fifth,
            final UnaryFunction<? super V, ? extends W> sixth,
            final UnaryFunction<? super W, ? extends X> seventh); static UnaryFunction<Q, Y> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third,
            final UnaryFunction<? super T, ? extends U> fourth,
            final UnaryFunction<? super U, ? extends V> fifth,
            final UnaryFunction<? super V, ? extends W> sixth,
            final UnaryFunction<? super W, ? extends X> seventh,
            final UnaryFunction<? super X, ? extends Y> eighth); static UnaryFunction<Q, Z> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third,
            final UnaryFunction<? super T, ? extends U> fourth,
            final UnaryFunction<? super U, ? extends V> fifth,
            final UnaryFunction<? super V, ? extends W> sixth,
            final UnaryFunction<? super W, ? extends X> seventh,
            final UnaryFunction<? super X, ? extends Y> eighth,
            final UnaryFunction<? super Y, ? extends Z> ninth); }
UnaryFunctions { public static <Q, R, S> UnaryFunction<Q, S> compose( final UnaryFunction<? super Q, ? extends R> first, final UnaryFunction<? super R, ? extends S> second) { return new UnaryFunction<Q, S>() { @Override public S call(Q input) { return second.call(first.call(input)); } }; } private  UnaryFunctions(); static UnaryFunction<T, T> identity(); static UnaryFunction<Q, S> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second); static UnaryFunction<Q, T> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third); static UnaryFunction<Q, U> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third,
            final UnaryFunction<? super T, ? extends U> fourth); static UnaryFunction<Q, V> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third,
            final UnaryFunction<? super T, ? extends U> fourth,
            final UnaryFunction<? super U, ? extends V> fifth); static UnaryFunction<Q, W> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third,
            final UnaryFunction<? super T, ? extends U> fourth,
            final UnaryFunction<? super U, ? extends V> fifth,
            final UnaryFunction<? super V, ? extends W> sixth); static UnaryFunction<Q, X> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third,
            final UnaryFunction<? super T, ? extends U> fourth,
            final UnaryFunction<? super U, ? extends V> fifth,
            final UnaryFunction<? super V, ? extends W> sixth,
            final UnaryFunction<? super W, ? extends X> seventh); static UnaryFunction<Q, Y> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third,
            final UnaryFunction<? super T, ? extends U> fourth,
            final UnaryFunction<? super U, ? extends V> fifth,
            final UnaryFunction<? super V, ? extends W> sixth,
            final UnaryFunction<? super W, ? extends X> seventh,
            final UnaryFunction<? super X, ? extends Y> eighth); static UnaryFunction<Q, Z> compose(
            final UnaryFunction<? super Q, ? extends R> first,
            final UnaryFunction<? super R, ? extends S> second,
            final UnaryFunction<? super S, ? extends T> third,
            final UnaryFunction<? super T, ? extends U> fourth,
            final UnaryFunction<? super U, ? extends V> fifth,
            final UnaryFunction<? super V, ? extends W> sixth,
            final UnaryFunction<? super W, ? extends X> seventh,
            final UnaryFunction<? super X, ? extends Y> eighth,
            final UnaryFunction<? super Y, ? extends Z> ninth);  }