/** * Create a {@link Tuple2} with the given objects. * * @param t1 The first value in the tuple. Not null. * @param t2 The second value in the tuple. Not null. * @param <T1> The type of the first value. * @param <T2> The type of the second value. * @return The new {@link Tuple2}. */ public static <T1, T2> Tuple2<T1, T2> of(T1 t1, T2 t2) { return new Tuple2<>(t1, t2); }
@Override public Tuple2 apply(Object o) { return fromArray((Object[])o); }
/** * Create a {@link Tuple3} with the given objects. * * @param t1 The first value in the tuple. Not null. * @param t2 The second value in the tuple. Not null. * @param t3 The third value in the tuple. Not null. * @param <T1> The type of the first value. * @param <T2> The type of the second value. * @param <T3> The type of the third value. * @return The new {@link Tuple3}. */ public static <T1, T2, T3> Tuple3<T1, T2, T3> of(T1 t1, T2 t2, T3 t3) { return new Tuple3<>(t1, t2, t3); }
Tuple2<Long, T> snapshot(T data){ long now = scheduler.now(TimeUnit.MILLISECONDS); long last = lastTime; lastTime = now; long delta = now - last; return Tuples.of(delta, data); }
/** * A Tuple String representation is the comma separated list of values, enclosed * in square brackets. * @return the Tuple String representation */ @Override public final String toString() { return Tuples.tupleStringRepresentation(toArray()).insert(0, '[').append(']').toString(); } }
/** * Map the 1st part (T1) of this {@link Tuple6} into a different value and type, * keeping the other parts. * * @param mapper the mapping {@link Function} for the T1 part * @param <R> the new type for the T1 part * @return a new {@link Tuple6} with a different T1 value */ public <R> Tuple6<R, T2, T3, T4, T5, T6> mapT1(Function<T1, R> mapper) { return new Tuple6<>(mapper.apply(t1), t2, t3, t4, t5, t6); }
/** * Map the 1st part (T1) of this {@link Tuple7} into a different value and type, * keeping the other parts. * * @param mapper the mapping {@link Function} for the T1 part * @param <R> the new type for the T1 part * @return a new {@link Tuple7} with a different T1 value */ public <R> Tuple7<R, T2, T3, T4, T5, T6, T7> mapT1(Function<T1, R> mapper) { return new Tuple7<>(mapper.apply(t1), t2, t3, t4, t5, t6, t7); }
/** * Create a {@link Tuple4} with the given objects. * * @param t1 The first value in the tuple. Not null. * @param t2 The second value in the tuple. Not null. * @param t3 The third value in the tuple. Not null. * @param t4 The fourth value in the tuple. Not null. * @param <T1> The type of the first value. * @param <T2> The type of the second value. * @param <T3> The type of the third value. * @param <T4> The type of the fourth value. * @return The new {@link Tuple4}. */ public static <T1, T2, T3, T4> Tuple4<T1, T2, T3, T4> of(T1 t1, T2 t2, T3 t3, T4 t4) { return new Tuple4<>(t1, t2, t3, t4); }
/** * Map the 2nd part (T2) of this {@link Tuple5} into a different value and type, * keeping the other parts. * * @param mapper the mapping {@link Function} for the T2 part * @param <R> the new type for the T2 part * @return a new {@link Tuple5} with a different T2 value */ public <R> Tuple5<T1, R, T3, T4, T5> mapT2(Function<T2, R> mapper) { return new Tuple5<>(t1, mapper.apply(t2), t3, t4, t5); }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + t4.hashCode(); return result; }
/** * Map the 3rd part (T3) of this {@link Tuple8} into a different value and type, * keeping the other parts. * * @param mapper the mapping {@link Function} for the T3 part * @param <R> the new type for the T3 part * @return a new {@link Tuple8} with a different T3 value */ public <R> Tuple8<T1, T2, R, T4, T5, T6, T7, T8> mapT3(Function<T3, R> mapper) { return new Tuple8<>(t1, t2, mapper.apply(t3), t4, t5, t6, t7, t8); }
/** * 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)); }
/** * Map the 5th part (T5) of this {@link Tuple6} into a different value and type, * keeping the other parts. * * @param mapper the mapping {@link Function} for the T5 part * @param <R> the new type for the T5 part * @return a new {@link Tuple6} with a different T5 value */ public <R> Tuple6<T1, T2, T3, T4, R, T6> mapT5(Function<T5, R> mapper) { return new Tuple6<>(t1, t2, t3, t4, mapper.apply(t5), t6); }
/** * Map the 3rd part (T3) of this {@link Tuple7} into a different value and type, * keeping the other parts. * * @param mapper the mapping {@link Function} for the T3 part * @param <R> the new type for the T3 part * @return a new {@link Tuple7} with a different T3 value */ public <R> Tuple7<T1, T2, R, T4, T5, T6, T7> mapT3(Function<T3, R> mapper) { return new Tuple7<>(t1, t2, mapper.apply(t3), t4, t5, t6, t7); }
/** * Map the 3rd part (T3) of this {@link Tuple3} into a different value and type, * keeping the other parts. * * @param mapper the mapping {@link Function} for the T3 part * @param <R> the new type for the T3 part * @return a new {@link Tuple3} with a different T3 value */ public <R> Tuple3<T1, T2, R> mapT3(Function<T3, R> mapper) { return new Tuple3<>(t1, t2, mapper.apply(t3)); }
/** * Map the 1st part (T1) of this {@link Tuple4} into a different value and type, * keeping the other parts. * * @param mapper the mapping {@link Function} for the T1 part * @param <R> the new type for the T1 part * @return a new {@link Tuple4} with a different T1 value */ public <R> Tuple4<R, T2, T3, T4> mapT1(Function<T1, R> mapper) { return new Tuple4<>(mapper.apply(t1), t2, t3, t4); }
/** * Map the 2nd part (T2) of this {@link Tuple6} into a different value and type, * keeping the other parts. * * @param mapper the mapping {@link Function} for the T2 part * @param <R> the new type for the T2 part * @return a new {@link Tuple6} with a different T2 value */ public <R> Tuple6<T1, R, T3, T4, T5, T6> mapT2(Function<T2, R> mapper) { return new Tuple6<>(t1, mapper.apply(t2), t3, t4, t5, t6); }
/** * Map the 5th part (T5) of this {@link Tuple7} into a different value and type, * keeping the other parts. * * @param mapper the mapping {@link Function} for the T5 part * @param <R> the new type for the T5 part * @return a new {@link Tuple7} with a different T5 value */ public <R> Tuple7<T1, T2, T3, T4, R, T6, T7> mapT5(Function<T5, R> mapper) { return new Tuple7<>(t1, t2, t3, t4, mapper.apply(t5), t6, t7); }
/** * Map the 4th part (T4) of this {@link Tuple6} into a different value and type, * keeping the other parts. * * @param mapper the mapping {@link Function} for the T4 part * @param <R> the new type for the T4 part * @return a new {@link Tuple6} with a different T4 value */ public <R> Tuple6<T1, T2, T3, R, T5, T6> mapT4(Function<T4, R> mapper) { return new Tuple6<>(t1, t2, t3, mapper.apply(t4), t5, t6); }
/** * Map the 6th part (T6) of this {@link Tuple7} into a different value and type, * keeping the other parts. * * @param mapper the mapping {@link Function} for the T6 part * @param <R> the new type for the T6 part * @return a new {@link Tuple7} with a different T6 value */ public <R> Tuple7<T1, T2, T3, T4, T5, R, T7> mapT6(Function<T6, R> mapper) { return new Tuple7<>(t1, t2, t3, t4, t5, mapper.apply(t6), t7); }