/** * Sets the 2nd element of this tuple to the given {@code value}. * * @param value the new value * @return a copy of this tuple with a new value for the 2nd element of this Tuple. */ public Tuple3<T1, T2, T3> update2(T2 value) { return new Tuple3<>(_1, value, _3); }
@Override public R apply(T obj) { return pattern.apply(obj).apply(f); }
@Override public int compareTo(Tuple3<T1, T2, T3> that) { return Tuple3.compareTo(this, that); }
@Override public <T1, T2, T3> Tuple3<Queue<T1>, Queue<T2>, Queue<T3>> unzip3(Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) { Objects.requireNonNull(unzipper, "unzipper is null"); return toList().unzip3(unzipper).map(io.vavr.collection.List::toQueue, io.vavr.collection.List::toQueue, io.vavr.collection.List::toQueue); }
@Override default <T1, T2, T3> Tuple3<Seq<T1>, Seq<T2>, Seq<T3>> unzip3( Function<? super Tuple2<K, V>, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) { Objects.requireNonNull(unzipper, "unzipper is null"); return iterator().unzip3(unzipper).map(Stream::ofAll, Stream::ofAll, Stream::ofAll); }
/** * Sets the 1st element of this tuple to the given {@code value}. * * @param value the new value * @return a copy of this tuple with a new value for the 1st element of this Tuple. */ public Tuple3<T1, T2, T3> update1(T1 value) { return new Tuple3<>(value, _2, _3); }
@Override default <T1, T2, T3> Tuple3<Seq<T1>, Seq<T2>, Seq<T3>> unzip3( Function<? super Tuple2<K, V>, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) { Objects.requireNonNull(unzipper, "unzipper is null"); return iterator().unzip3(unzipper).map(Stream::ofAll, Stream::ofAll, Stream::ofAll); }
@Override public R apply(T obj) { return pattern.apply(obj).apply(f); }
@Override public int compareTo(Tuple3<T1, T2, T3> that) { return Tuple3.compareTo(this, that); }
/** * Sets the 3rd element of this tuple to the given {@code value}. * * @param value the new value * @return a copy of this tuple with a new value for the 3rd element of this Tuple. */ public Tuple3<T1, T2, T3> update3(T3 value) { return new Tuple3<>(_1, _2, value); }
@Override public <T1, T2, T3> Tuple3<TreeSet<T1>, TreeSet<T2>, TreeSet<T3>> unzip3( Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) { Objects.requireNonNull(unzipper, "unzipper is null"); return iterator().unzip3(unzipper).map( i1 -> TreeSet.ofAll(Comparators.naturalComparator(), i1), i2 -> TreeSet.ofAll(Comparators.naturalComparator(), i2), i3 -> TreeSet.ofAll(Comparators.naturalComparator(), i3)); }
/** * Creates a tuple of three elements. * * @param <T1> type of the 1st element * @param <T2> type of the 2nd element * @param <T3> type of the 3rd element * @param t1 the 1st element * @param t2 the 2nd element * @param t3 the 3rd element * @return a tuple of three elements. */ static <T1, T2, T3> Tuple3<T1, T2, T3> of(T1 t1, T2 t2, T3 t3) { return new Tuple3<>(t1, t2, t3); }
@Override default <T1, T2, T3> Tuple3<TreeSet<T1>, TreeSet<T2>, TreeSet<T3>> unzip3( Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) { Objects.requireNonNull(unzipper, "unzipper is null"); return iterator().unzip3(unzipper).map( i1 -> TreeSet.ofAll(Comparators.naturalComparator(), i1), i2 -> TreeSet.ofAll(Comparators.naturalComparator(), i2), i3 -> TreeSet.ofAll(Comparators.naturalComparator(), i3)); }
/** * Turns a sequence of {@code Tuple3} into a Tuple3 of {@code Seq}s. * * @param <T1> 1st component type * @param <T2> 2nd component type * @param <T3> 3rd component type * @param tuples an {@code Iterable} of tuples * @return a tuple of three {@link Seq}s. */ static <T1, T2, T3> Tuple3<Seq<T1>, Seq<T2>, Seq<T3>> sequence3(Iterable<? extends Tuple3<? extends T1, ? extends T2, ? extends T3>> tuples) { Objects.requireNonNull(tuples, "tuples is null"); final Stream<Tuple3<? extends T1, ? extends T2, ? extends T3>> s = Stream.ofAll(tuples); return new Tuple3<>(s.map(Tuple3::_1), s.map(Tuple3::_2), s.map(Tuple3::_3)); }
@Override default <T1, T2, T3> Tuple3<Seq<T1>, Seq<T2>, Seq<T3>> unzip3( Function<? super Tuple2<K, V>, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) { Objects.requireNonNull(unzipper, "unzipper is null"); return iterator().unzip3(unzipper).map(Stream::ofAll, Stream::ofAll, Stream::ofAll); }
@Test public void testTuple3CollectorWithSelectedKeyValueShouldSucceed() { List<Tuple3<Integer, String, String>> expectedTuples = expected.map(i -> new Tuple3<>(i, "t2" + i, "t3" + (i + 1))); List<Tuple3<Integer, String, String>> tupleProjection = dbRule.getSharedHandle() .createQuery("select t1, t2, t3 from tuples") .collectInto(new GenericType<List<Tuple3<Integer, String, String>>>() {}); assertThat(tupleProjection).containsOnlyElementsOf(expectedTuples); }
@Override public <T1, T2, T3> Tuple3<Queue<T1>, Queue<T2>, Queue<T3>> unzip3(Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) { Objects.requireNonNull(unzipper, "unzipper is null"); return toList().unzip3(unzipper).map(io.vavr.collection.List::toQueue, io.vavr.collection.List::toQueue, io.vavr.collection.List::toQueue); }
/** * Sets the 1st element of this tuple to the given {@code value}. * * @param value the new value * @return a copy of this tuple with a new value for the 1st element of this Tuple. */ public Tuple3<T1, T2, T3> update1(T1 value) { return new Tuple3<>(value, _2, _3); }
@Override default <T1, T2, T3> Tuple3<Seq<T1>, Seq<T2>, Seq<T3>> unzip3( Function<? super Tuple2<K, V>, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) { Objects.requireNonNull(unzipper, "unzipper is null"); return iterator().unzip3(unzipper).map(Stream::ofAll, Stream::ofAll, Stream::ofAll); }
/** * Sets the 3rd element of this tuple to the given {@code value}. * * @param value the new value * @return a copy of this tuple with a new value for the 3rd element of this Tuple. */ public Tuple3<T1, T2, T3> update3(T3 value) { return new Tuple3<>(_1, _2, value); }