
javaslang.Tuple Maven / Gradle / Ivy
/* / \____ _ _ ____ ______ / \ ____ __ _______
* / / \/ \ / \/ \ / /\__\/ // \/ \ // /\__\ JΛVΛSLΛNG
* _/ / /\ \ \/ / /\ \\__\\ \ // /\ \ /\\/ \ /__\ \ Copyright 2014-2016 Javaslang, http://javaslang.io
* /___/\_/ \_/\____/\_/ \_/\__\/__/\__\_/ \_// \__/\_____/ Licensed under the Apache License, Version 2.0
*/
package javaslang;
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*\
G E N E R A T O R C R A F T E D
\*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
import javaslang.collection.Seq;
/**
* The base interface of all tuples.
*
* @author Daniel Dietrich
* @since 1.1.0
*/
public interface Tuple {
/**
* Returns the number of elements of this tuple.
*
* @return the number of elements.
*/
int arity();
/**
* Converts this tuple to a sequence.
*
* @return A new {@code Seq}.
*/
Seq> toSeq();
// -- factory methods
/**
* Creates the empty tuple.
*
* @return the empty tuple.
*/
static Tuple0 empty() {
return Tuple0.instance();
}
/**
* Creates a tuple of one element.
*
* @param type of the 1st element
* @param t1 the 1st element
* @return a tuple of one element.
*/
static Tuple1 of(T1 t1) {
return new Tuple1<>(t1);
}
/**
* Creates a tuple of two elements.
*
* @param type of the 1st element
* @param type of the 2nd element
* @param t1 the 1st element
* @param t2 the 2nd element
* @return a tuple of two elements.
*/
static Tuple2 of(T1 t1, T2 t2) {
return new Tuple2<>(t1, t2);
}
/**
* Creates a tuple of three elements.
*
* @param type of the 1st element
* @param type of the 2nd element
* @param 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 Tuple3 of(T1 t1, T2 t2, T3 t3) {
return new Tuple3<>(t1, t2, t3);
}
/**
* Creates a tuple of 4 elements.
*
* @param type of the 1st element
* @param type of the 2nd element
* @param type of the 3rd element
* @param type of the 4th element
* @param t1 the 1st element
* @param t2 the 2nd element
* @param t3 the 3rd element
* @param t4 the 4th element
* @return a tuple of 4 elements.
*/
static Tuple4 of(T1 t1, T2 t2, T3 t3, T4 t4) {
return new Tuple4<>(t1, t2, t3, t4);
}
/**
* Creates a tuple of 5 elements.
*
* @param type of the 1st element
* @param type of the 2nd element
* @param type of the 3rd element
* @param type of the 4th element
* @param type of the 5th element
* @param t1 the 1st element
* @param t2 the 2nd element
* @param t3 the 3rd element
* @param t4 the 4th element
* @param t5 the 5th element
* @return a tuple of 5 elements.
*/
static Tuple5 of(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) {
return new Tuple5<>(t1, t2, t3, t4, t5);
}
/**
* Creates a tuple of 6 elements.
*
* @param type of the 1st element
* @param type of the 2nd element
* @param type of the 3rd element
* @param type of the 4th element
* @param type of the 5th element
* @param type of the 6th element
* @param t1 the 1st element
* @param t2 the 2nd element
* @param t3 the 3rd element
* @param t4 the 4th element
* @param t5 the 5th element
* @param t6 the 6th element
* @return a tuple of 6 elements.
*/
static Tuple6 of(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) {
return new Tuple6<>(t1, t2, t3, t4, t5, t6);
}
/**
* Creates a tuple of 7 elements.
*
* @param type of the 1st element
* @param type of the 2nd element
* @param type of the 3rd element
* @param type of the 4th element
* @param type of the 5th element
* @param type of the 6th element
* @param type of the 7th element
* @param t1 the 1st element
* @param t2 the 2nd element
* @param t3 the 3rd element
* @param t4 the 4th element
* @param t5 the 5th element
* @param t6 the 6th element
* @param t7 the 7th element
* @return a tuple of 7 elements.
*/
static Tuple7 of(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) {
return new Tuple7<>(t1, t2, t3, t4, t5, t6, t7);
}
/**
* Creates a tuple of 8 elements.
*
* @param type of the 1st element
* @param type of the 2nd element
* @param type of the 3rd element
* @param type of the 4th element
* @param type of the 5th element
* @param type of the 6th element
* @param type of the 7th element
* @param type of the 8th element
* @param t1 the 1st element
* @param t2 the 2nd element
* @param t3 the 3rd element
* @param t4 the 4th element
* @param t5 the 5th element
* @param t6 the 6th element
* @param t7 the 7th element
* @param t8 the 8th element
* @return a tuple of 8 elements.
*/
static Tuple8 of(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) {
return new Tuple8<>(t1, t2, t3, t4, t5, t6, t7, t8);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy