/** * A converting function from Object array to {@link Tuples} to R. * * @param <R> The type of the return value. * @param delegate the function to delegate to * * @return The unchecked conversion function to R. */ public static <R> Function<Object[], R> fnAny(final Function<Tuple2, R> delegate) { return objects -> delegate.apply(Tuples.fnAny().apply(objects)); }
@Override public Publisher<V> apply(List<? extends Publisher<?>> publishers) { return zip(Tuples.fnAny((Function<Tuple2, V>) combinator), publishers.toArray(new Publisher[publishers .size()])); } }));
@Test @SuppressWarnings("unchecked") public void fnAny() { Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8 }; Tuple2<Object, Object> tuple = Tuples.fnAny().apply(source); assertThat(tuple.getT1()).isEqualTo(1); assertThat(tuple.getT2()).isEqualTo(2); assertThat(tuple) .isInstanceOf(Tuple8.class) .containsExactly(1, 2, 3, 4, 5, 6, 7, 8); }
@Test public void fnAnyDelegate() { Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8 }; Function<Tuple2, Tuple2<Object, Object>> invert = t2 -> new Tuple2<>(t2.getT2(), t2.getT1()); Tuple2<Object, Object> tuple = Tuples.fnAny(invert).apply(source); assertThat(tuple.getT1()).isEqualTo(2); assertThat(tuple.getT2()).isEqualTo(1); assertThat(tuple) .isExactlyInstanceOf(Tuple2.class) .containsExactly(2, 1); }
/** * A converting function from Object array to {@link Tuples} to R. * * @param <R> The type of the return value. * @param delegate the function to delegate to * * @return The unchecked conversion function to R. */ public static <R> Function<Object[], R> fnAny(final Function<Tuple2, R> delegate) { return objects -> delegate.apply(Tuples.fnAny().apply(objects)); }
@Override public Publisher<V> apply(List<? extends Publisher<?>> publishers) { return zip(Tuples.fnAny((Function<Tuple2, V>) combinator), publishers.toArray(new Publisher[publishers .size()])); } }));