Package io.vavr
Interface Tuple
- All Known Implementing Classes:
Tuple0
,Tuple1
,Tuple2
,Tuple3
,Tuple4
,Tuple5
,Tuple6
,Tuple7
,Tuple8
public interface Tuple
The base interface of all tuples.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionint
arity()
Returns the number of elements of this tuple.static Tuple0
empty()
Creates the empty tuple.static <T1,
T2> Tuple2 <T1, T2> Creates aTuple2
from aMap.Entry
.static int
Return the order-dependent hash of the one given value.static int
Return the order-dependent hash of the two given values.static int
Return the order-dependent hash of the three given values.static int
Return the order-dependent hash of the 4 given values.static int
Return the order-dependent hash of the 5 given values.static int
Return the order-dependent hash of the 6 given values.static int
Return the order-dependent hash of the 7 given values.static int
Return the order-dependent hash of the 8 given values.static <T1> Tuple1
<T1> Narrows a widenedTuple1<? extends T1>
toTuple1<T1>
.static <T1,
T2> Tuple2 <T1, T2> Narrows a widenedTuple2<? extends T1, ? extends T2>
toTuple2<T1, T2>
.static <T1,
T2, T3>
Tuple3<T1, T2, T3> Narrows a widenedTuple3<? extends T1, ? extends T2, ? extends T3>
toTuple3<T1, T2, T3>
.static <T1,
T2, T3, T4>
Tuple4<T1, T2, T3, T4> Narrows a widenedTuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4>
toTuple4<T1, T2, T3, T4>
.static <T1,
T2, T3, T4, T5>
Tuple5<T1, T2, T3, T4, T5> Narrows a widenedTuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5>
toTuple5<T1, T2, T3, T4, T5>
.static <T1,
T2, T3, T4, T5, T6>
Tuple6<T1, T2, T3, T4, T5, T6> Narrows a widenedTuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6>
toTuple6<T1, T2, T3, T4, T5, T6>
.static <T1,
T2, T3, T4, T5, T6, T7>
Tuple7<T1, T2, T3, T4, T5, T6, T7> narrow
(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> t) Narrows a widenedTuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7>
toTuple7<T1, T2, T3, T4, T5, T6, T7>
.static <T1,
T2, T3, T4, T5, T6, T7, T8>
Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> narrow
(Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> t) Narrows a widenedTuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8>
toTuple8<T1, T2, T3, T4, T5, T6, T7, T8>
.static <T1> Tuple1
<T1> of
(T1 t1) Creates a tuple of one element.static <T1,
T2> Tuple2 <T1, T2> of
(T1 t1, T2 t2) Creates a tuple of two elements.static <T1,
T2, T3>
Tuple3<T1, T2, T3> of
(T1 t1, T2 t2, T3 t3) Creates a tuple of three elements.static <T1,
T2, T3, T4>
Tuple4<T1, T2, T3, T4> of
(T1 t1, T2 t2, T3 t3, T4 t4) Creates a tuple of 4 elements.static <T1,
T2, T3, T4, T5>
Tuple5<T1, T2, T3, T4, T5> of
(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) Creates a tuple of 5 elements.static <T1,
T2, T3, T4, T5, T6>
Tuple6<T1, T2, T3, T4, T5, T6> of
(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) Creates a tuple of 6 elements.static <T1,
T2, T3, T4, T5, T6, T7>
Tuple7<T1, T2, T3, T4, T5, T6, T7> of
(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) Creates a tuple of 7 elements.static <T1,
T2, T3, T4, T5, T6, T7, T8>
Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> of
(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) Creates a tuple of 8 elements.Turns a sequence ofTuple1
into a Tuple1 ofSeq
.Turns a sequence ofTuple2
into a Tuple2 ofSeq
s.Turns a sequence ofTuple3
into a Tuple3 ofSeq
s.Turns a sequence ofTuple4
into a Tuple4 ofSeq
s.sequence5
(Iterable<? extends Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5>> tuples) Turns a sequence ofTuple5
into a Tuple5 ofSeq
s.sequence6
(Iterable<? extends Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6>> tuples) Turns a sequence ofTuple6
into a Tuple6 ofSeq
s.sequence7
(Iterable<? extends Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7>> tuples) Turns a sequence ofTuple7
into a Tuple7 ofSeq
s.static <T1,
T2, T3, T4, T5, T6, T7, T8>
Tuple8<Seq<T1>, Seq<T2>, Seq<T3>, Seq<T4>, Seq<T5>, Seq<T6>, Seq<T7>, Seq<T8>> sequence8
(Iterable<? extends Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8>> tuples) Turns a sequence ofTuple8
into a Tuple8 ofSeq
s.Seq
<?> toSeq()
Converts this tuple to a sequence.
-
Field Details
-
MAX_ARITY
static final int MAX_ARITYThe maximum arity of an Tuple.Note: This value might be changed in a future version of Vavr. So it is recommended to use this constant instead of hardcoding the current maximum arity.
- See Also:
-
-
Method Details
-
arity
int arity()Returns the number of elements of this tuple.- Returns:
- the number of elements.
-
toSeq
Seq<?> toSeq()Converts this tuple to a sequence.- Returns:
- A new
Seq
.
-
empty
Creates the empty tuple.- Returns:
- the empty tuple.
-
fromEntry
Creates aTuple2
from aMap.Entry
.- Type Parameters:
T1
- Type of first component (entry key)T2
- Type of second component (entry value)- Parameters:
entry
- AMap.Entry
- Returns:
- a new
Tuple2
containing key and value of the givenentry
-
of
Creates a tuple of one element.- Type Parameters:
T1
- type of the 1st element- Parameters:
t1
- the 1st element- Returns:
- a tuple of one element.
-
of
Creates a tuple of two elements.- Type Parameters:
T1
- type of the 1st elementT2
- type of the 2nd element- Parameters:
t1
- the 1st elementt2
- the 2nd element- Returns:
- a tuple of two elements.
-
of
Creates a tuple of three elements.- Type Parameters:
T1
- type of the 1st elementT2
- type of the 2nd elementT3
- type of the 3rd element- Parameters:
t1
- the 1st elementt2
- the 2nd elementt3
- the 3rd element- Returns:
- a tuple of three elements.
-
of
Creates a tuple of 4 elements.- Type Parameters:
T1
- type of the 1st elementT2
- type of the 2nd elementT3
- type of the 3rd elementT4
- type of the 4th element- Parameters:
t1
- the 1st elementt2
- the 2nd elementt3
- the 3rd elementt4
- the 4th element- Returns:
- a tuple of 4 elements.
-
of
Creates a tuple of 5 elements.- Type Parameters:
T1
- type of the 1st elementT2
- type of the 2nd elementT3
- type of the 3rd elementT4
- type of the 4th elementT5
- type of the 5th element- Parameters:
t1
- the 1st elementt2
- the 2nd elementt3
- the 3rd elementt4
- the 4th elementt5
- the 5th element- Returns:
- a tuple of 5 elements.
-
of
static <T1,T2, Tuple6<T1,T3, T4, T5, T6> T2, ofT3, T4, T5, T6> (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) Creates a tuple of 6 elements.- Type Parameters:
T1
- type of the 1st elementT2
- type of the 2nd elementT3
- type of the 3rd elementT4
- type of the 4th elementT5
- type of the 5th elementT6
- type of the 6th element- Parameters:
t1
- the 1st elementt2
- the 2nd elementt3
- the 3rd elementt4
- the 4th elementt5
- the 5th elementt6
- the 6th element- Returns:
- a tuple of 6 elements.
-
of
static <T1,T2, Tuple7<T1,T3, T4, T5, T6, T7> T2, ofT3, T4, T5, T6, T7> (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) Creates a tuple of 7 elements.- Type Parameters:
T1
- type of the 1st elementT2
- type of the 2nd elementT3
- type of the 3rd elementT4
- type of the 4th elementT5
- type of the 5th elementT6
- type of the 6th elementT7
- type of the 7th element- Parameters:
t1
- the 1st elementt2
- the 2nd elementt3
- the 3rd elementt4
- the 4th elementt5
- the 5th elementt6
- the 6th elementt7
- the 7th element- Returns:
- a tuple of 7 elements.
-
of
static <T1,T2, Tuple8<T1,T3, T4, T5, T6, T7, T8> T2, ofT3, T4, T5, T6, T7, T8> (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) Creates a tuple of 8 elements.- Type Parameters:
T1
- type of the 1st elementT2
- type of the 2nd elementT3
- type of the 3rd elementT4
- type of the 4th elementT5
- type of the 5th elementT6
- type of the 6th elementT7
- type of the 7th elementT8
- type of the 8th element- Parameters:
t1
- the 1st elementt2
- the 2nd elementt3
- the 3rd elementt4
- the 4th elementt5
- the 5th elementt6
- the 6th elementt7
- the 7th elementt8
- the 8th element- Returns:
- a tuple of 8 elements.
-
hash
Return the order-dependent hash of the one given value.- Parameters:
o1
- the 1st value to hash- Returns:
- the same result as
Objects.hashCode(Object)
-
hash
Return the order-dependent hash of the two given values.- Parameters:
o1
- the 1st value to hasho2
- the 2nd value to hash- Returns:
- the same result as
Objects.hash(Object...)
-
hash
Return the order-dependent hash of the three given values.- Parameters:
o1
- the 1st value to hasho2
- the 2nd value to hasho3
- the 3rd value to hash- Returns:
- the same result as
Objects.hash(Object...)
-
hash
Return the order-dependent hash of the 4 given values.- Parameters:
o1
- the 1st value to hasho2
- the 2nd value to hasho3
- the 3rd value to hasho4
- the 4th value to hash- Returns:
- the same result as
Objects.hash(Object...)
-
hash
Return the order-dependent hash of the 5 given values.- Parameters:
o1
- the 1st value to hasho2
- the 2nd value to hasho3
- the 3rd value to hasho4
- the 4th value to hasho5
- the 5th value to hash- Returns:
- the same result as
Objects.hash(Object...)
-
hash
Return the order-dependent hash of the 6 given values.- Parameters:
o1
- the 1st value to hasho2
- the 2nd value to hasho3
- the 3rd value to hasho4
- the 4th value to hasho5
- the 5th value to hasho6
- the 6th value to hash- Returns:
- the same result as
Objects.hash(Object...)
-
hash
Return the order-dependent hash of the 7 given values.- Parameters:
o1
- the 1st value to hasho2
- the 2nd value to hasho3
- the 3rd value to hasho4
- the 4th value to hasho5
- the 5th value to hasho6
- the 6th value to hasho7
- the 7th value to hash- Returns:
- the same result as
Objects.hash(Object...)
-
hash
static int hash(Object o1, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7, Object o8) Return the order-dependent hash of the 8 given values.- Parameters:
o1
- the 1st value to hasho2
- the 2nd value to hasho3
- the 3rd value to hasho4
- the 4th value to hasho5
- the 5th value to hasho6
- the 6th value to hasho7
- the 7th value to hasho8
- the 8th value to hash- Returns:
- the same result as
Objects.hash(Object...)
-
narrow
Narrows a widenedTuple1<? extends T1>
toTuple1<T1>
. This is eligible because immutable/read-only tuples are covariant.- Type Parameters:
T1
- the 1st component type- Parameters:
t
- ATuple1
.- Returns:
- the given
t
instance as narrowed typeTuple1<T1>
.
-
narrow
Narrows a widenedTuple2<? extends T1, ? extends T2>
toTuple2<T1, T2>
. This is eligible because immutable/read-only tuples are covariant.- Type Parameters:
T1
- the 1st component typeT2
- the 2nd component type- Parameters:
t
- ATuple2
.- Returns:
- the given
t
instance as narrowed typeTuple2<T1, T2>
.
-
narrow
Narrows a widenedTuple3<? extends T1, ? extends T2, ? extends T3>
toTuple3<T1, T2, T3>
. This is eligible because immutable/read-only tuples are covariant.- Type Parameters:
T1
- the 1st component typeT2
- the 2nd component typeT3
- the 3rd component type- Parameters:
t
- ATuple3
.- Returns:
- the given
t
instance as narrowed typeTuple3<T1, T2, T3>
.
-
narrow
static <T1,T2, Tuple4<T1,T3, T4> T2, narrowT3, T4> (Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> t) Narrows a widenedTuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4>
toTuple4<T1, T2, T3, T4>
. This is eligible because immutable/read-only tuples are covariant.- Type Parameters:
T1
- the 1st component typeT2
- the 2nd component typeT3
- the 3rd component typeT4
- the 4th component type- Parameters:
t
- ATuple4
.- Returns:
- the given
t
instance as narrowed typeTuple4<T1, T2, T3, T4>
.
-
narrow
static <T1,T2, Tuple5<T1,T3, T4, T5> T2, narrowT3, T4, T5> (Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> t) Narrows a widenedTuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5>
toTuple5<T1, T2, T3, T4, T5>
. This is eligible because immutable/read-only tuples are covariant.- Type Parameters:
T1
- the 1st component typeT2
- the 2nd component typeT3
- the 3rd component typeT4
- the 4th component typeT5
- the 5th component type- Parameters:
t
- ATuple5
.- Returns:
- the given
t
instance as narrowed typeTuple5<T1, T2, T3, T4, T5>
.
-
narrow
static <T1,T2, Tuple6<T1,T3, T4, T5, T6> T2, narrowT3, T4, T5, T6> (Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> t) Narrows a widenedTuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6>
toTuple6<T1, T2, T3, T4, T5, T6>
. This is eligible because immutable/read-only tuples are covariant.- Type Parameters:
T1
- the 1st component typeT2
- the 2nd component typeT3
- the 3rd component typeT4
- the 4th component typeT5
- the 5th component typeT6
- the 6th component type- Parameters:
t
- ATuple6
.- Returns:
- the given
t
instance as narrowed typeTuple6<T1, T2, T3, T4, T5, T6>
.
-
narrow
static <T1,T2, Tuple7<T1,T3, T4, T5, T6, T7> T2, narrowT3, T4, T5, T6, T7> (Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> t) Narrows a widenedTuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7>
toTuple7<T1, T2, T3, T4, T5, T6, T7>
. This is eligible because immutable/read-only tuples are covariant.- Type Parameters:
T1
- the 1st component typeT2
- the 2nd component typeT3
- the 3rd component typeT4
- the 4th component typeT5
- the 5th component typeT6
- the 6th component typeT7
- the 7th component type- Parameters:
t
- ATuple7
.- Returns:
- the given
t
instance as narrowed typeTuple7<T1, T2, T3, T4, T5, T6, T7>
.
-
narrow
static <T1,T2, Tuple8<T1,T3, T4, T5, T6, T7, T8> T2, narrowT3, T4, T5, T6, T7, T8> (Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> t) Narrows a widenedTuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8>
toTuple8<T1, T2, T3, T4, T5, T6, T7, T8>
. This is eligible because immutable/read-only tuples are covariant.- Type Parameters:
T1
- the 1st component typeT2
- the 2nd component typeT3
- the 3rd component typeT4
- the 4th component typeT5
- the 5th component typeT6
- the 6th component typeT7
- the 7th component typeT8
- the 8th component type- Parameters:
t
- ATuple8
.- Returns:
- the given
t
instance as narrowed typeTuple8<T1, T2, T3, T4, T5, T6, T7, T8>
.
-
sequence1
Turns a sequence ofTuple1
into a Tuple1 ofSeq
.- Type Parameters:
T1
- 1st component type- Parameters:
tuples
- anIterable
of tuples- Returns:
- a tuple of one
Seq
.
-
sequence2
static <T1,T2> Tuple2<Seq<T1>,Seq<T2>> sequence2(Iterable<? extends Tuple2<? extends T1, ? extends T2>> tuples) Turns a sequence ofTuple2
into a Tuple2 ofSeq
s.- Type Parameters:
T1
- 1st component typeT2
- 2nd component type- Parameters:
tuples
- anIterable
of tuples- Returns:
- a tuple of two
Seq
s.
-
sequence3
static <T1,T2, Tuple3<Seq<T1>,T3> Seq<T2>, sequence3Seq<T3>> (Iterable<? extends Tuple3<? extends T1, ? extends T2, ? extends T3>> tuples) Turns a sequence ofTuple3
into a Tuple3 ofSeq
s.- Type Parameters:
T1
- 1st component typeT2
- 2nd component typeT3
- 3rd component type- Parameters:
tuples
- anIterable
of tuples- Returns:
- a tuple of three
Seq
s.
-
sequence4
static <T1,T2, Tuple4<Seq<T1>,T3, T4> Seq<T2>, sequence4Seq<T3>, Seq<T4>> (Iterable<? extends Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4>> tuples) Turns a sequence ofTuple4
into a Tuple4 ofSeq
s.- Type Parameters:
T1
- 1st component typeT2
- 2nd component typeT3
- 3rd component typeT4
- 4th component type- Parameters:
tuples
- anIterable
of tuples- Returns:
- a tuple of 4
Seq
s.
-
sequence5
static <T1,T2, Tuple5<Seq<T1>,T3, T4, T5> Seq<T2>, sequence5Seq<T3>, Seq<T4>, Seq<T5>> (Iterable<? extends Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5>> tuples) Turns a sequence ofTuple5
into a Tuple5 ofSeq
s.- Type Parameters:
T1
- 1st component typeT2
- 2nd component typeT3
- 3rd component typeT4
- 4th component typeT5
- 5th component type- Parameters:
tuples
- anIterable
of tuples- Returns:
- a tuple of 5
Seq
s.
-
sequence6
static <T1,T2, Tuple6<Seq<T1>,T3, T4, T5, T6> Seq<T2>, sequence6Seq<T3>, Seq<T4>, Seq<T5>, Seq<T6>> (Iterable<? extends Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6>> tuples) Turns a sequence ofTuple6
into a Tuple6 ofSeq
s.- Type Parameters:
T1
- 1st component typeT2
- 2nd component typeT3
- 3rd component typeT4
- 4th component typeT5
- 5th component typeT6
- 6th component type- Parameters:
tuples
- anIterable
of tuples- Returns:
- a tuple of 6
Seq
s.
-
sequence7
static <T1,T2, Tuple7<Seq<T1>,T3, T4, T5, T6, T7> Seq<T2>, sequence7Seq<T3>, Seq<T4>, Seq<T5>, Seq<T6>, Seq<T7>> (Iterable<? extends Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7>> tuples) Turns a sequence ofTuple7
into a Tuple7 ofSeq
s.- Type Parameters:
T1
- 1st component typeT2
- 2nd component typeT3
- 3rd component typeT4
- 4th component typeT5
- 5th component typeT6
- 6th component typeT7
- 7th component type- Parameters:
tuples
- anIterable
of tuples- Returns:
- a tuple of 7
Seq
s.
-
sequence8
static <T1,T2, Tuple8<Seq<T1>,T3, T4, T5, T6, T7, T8> Seq<T2>, sequence8Seq<T3>, Seq<T4>, Seq<T5>, Seq<T6>, Seq<T7>, Seq<T8>> (Iterable<? extends Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8>> tuples) Turns a sequence ofTuple8
into a Tuple8 ofSeq
s.- Type Parameters:
T1
- 1st component typeT2
- 2nd component typeT3
- 3rd component typeT4
- 4th component typeT5
- 5th component typeT6
- 6th component typeT7
- 7th component typeT8
- 8th component type- Parameters:
tuples
- anIterable
of tuples- Returns:
- a tuple of 8
Seq
s.
-