Interface ComparableTuple<CONCRETE_TUPLE extends ComparableTuple<CONCRETE_TUPLE>>
- Type Parameters:
CONCRETE_TUPLE- the concreteComparableTuplesub-type
- All Superinterfaces:
Comparable<CONCRETE_TUPLE>,Serializable
- All Known Implementing Classes:
ComparableEmpty,ComparablePair,ComparableSingle,ComparableTriple
public interface ComparableTuple<CONCRETE_TUPLE extends ComparableTuple<CONCRETE_TUPLE>>
extends Comparable<CONCRETE_TUPLE>, Serializable
Base interface for all
A
Note:
ComparableTuple's.A
ComparableTuple is an immutable object that can contain the following (supported) number of elements:
| Number of element in Tuple | Concrete ComparableTuple type | Factory method |
| 0 | ComparableEmpty | empty() |
| 1 | ComparableSingle | of(Comparable) |
| 2 | ComparablePair | of(Comparable, Comparable) |
| 3 | ComparableTriple | of(Comparable, Comparable, Comparable) |
Note:
ComparableTuple (and its subclasses) supports Object.equals(Object) comparison using subclasses for the different subclasses-
Method Summary
Modifier and TypeMethodDescriptionintarity()Number of arguments/elements in the Tuplestatic ComparableEmptyempty()Create/Get andComparableEmptyComparableTuplestatic <T1 extends Comparable<? super T1>,T2 extends Comparable<? super T2>>
ComparablePair<T1,T2> static ComparableEmptyof()Create/Get andComparableEmptyTuplestatic <T1 extends Comparable<? super T1>>
ComparableSingle<T1>of(T1 t1) Create a newComparableTuplewith 1 elementstatic <T1 extends Comparable<? super T1>,T2 extends Comparable<? super T2>>
ComparablePair<T1,T2> of(T1 t1, T2 t2) Create a newComparableTuplewith 2 elementsstatic <T1 extends Comparable<? super T1>,T2 extends Comparable<? super T2>, T3 extends Comparable<? super T3>>
ComparableTriple<T1,T2, T3> of(T1 t1, T2 t2, T3 t3) Create a newComparableTuplewith 3 elementsList<?>toList()Convert the Tuple to a listMethods inherited from interface java.lang.Comparable
compareTo
-
Method Details
-
arity
int arity()Number of arguments/elements in the Tuple- Returns:
- Number of arguments/elements in the Tuple
-
toList
List<?> toList()Convert the Tuple to a list- Returns:
- list of all Tuple elements
-
empty
Create/Get andComparableEmptyComparableTuple- Returns:
- an
ComparableEmptyTuple
-
of
Create/Get andComparableEmptyTuple- Returns:
- an
ComparableEmptyTuple
-
of
Create a newComparableTuplewith 1 element- Type Parameters:
T1- the first element type- Parameters:
t1- the first element- Returns:
- the newly created
ComparableSingletuple
-
of
static <T1 extends Comparable<? super T1>,T2 extends Comparable<? super T2>> ComparablePair<T1,T2> of(T1 t1, T2 t2) Create a newComparableTuplewith 2 elements- Type Parameters:
T1- the first element typeT2- the second element type- Parameters:
t1- the first elementt2- the second element- Returns:
- the newly created
ComparablePairtuple
-
fromEntry
static <T1 extends Comparable<? super T1>,T2 extends Comparable<? super T2>> ComparablePair<T1,T2> fromEntry(Map.Entry<? extends T1, ? extends T2> entry) - Type Parameters:
T1- the first element typeT2- the second element type- Parameters:
entry- the map entry- Returns:
- the newly created
ComparablePairtuple
-
of
static <T1 extends Comparable<? super T1>,T2 extends Comparable<? super T2>, ComparableTriple<T1,T3 extends Comparable<? super T3>> T2, ofT3> (T1 t1, T2 t2, T3 t3) Create a newComparableTuplewith 3 elements- Type Parameters:
T1- the first element typeT2- the second element typeT3- the third element type- Parameters:
t1- the first elementt2- the second elementt3- the third element- Returns:
- the newly created
ComparableTripletuple
-