Interface Tuple<CONCRETE_TUPLE extends Tuple<CONCRETE_TUPLE>>

Type Parameters:
CONCRETE_TUPLE - the concrete Tuple sub-type
All Superinterfaces:
Serializable
All Known Implementing Classes:
Either, Empty, Pair, Single, Triple

public interface Tuple<CONCRETE_TUPLE extends Tuple<CONCRETE_TUPLE>> extends Serializable
Base interface for all Tuple's.
A Tuple is an immutable object that can contain the following (supported) number of elements:
Number of element in TupleConcrete Tuple typeFactory method
0Emptyempty()
1Singleof(Object)
2Pairof(Object, Object)
3Tripleof(Object, Object, Object)

Note: Tuple (and its subclasses) supports Object.equals(Object) comparison using subclasses for the different subclasses
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Number of arguments/elements in the Tuple
    static Empty
    Create/Get and Empty Tuple
    static <T1, T2> Pair<T1,T2>
    fromEntry(Map.Entry<? extends T1,? extends T2> entry)
    Create a new Tuple with 2 elements from a Map Map.Entry
    static Empty
    of()
    Create/Get and Empty Tuple
    static <T1> Single<T1>
    of(T1 t1)
    Create a new Tuple with 1 element
    static <T1, T2> Pair<T1,T2>
    of(T1 t1, T2 t2)
    Create a new Tuple with 2 elements
    static <T1, T2, T3> Triple<T1,T2,T3>
    of(T1 t1, T2 t2, T3 t3)
    Create a new Tuple with 3 elements
    List<?>
    Convert the Tuple to a list
  • 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

      static Empty empty()
      Create/Get and Empty Tuple
      Returns:
      an Empty Tuple
    • of

      static Empty of()
      Create/Get and Empty Tuple
      Returns:
      an Empty Tuple
    • of

      static <T1> Single<T1> of(T1 t1)
      Create a new Tuple with 1 element
      Type Parameters:
      T1 - the first element type
      Parameters:
      t1 - the first element
      Returns:
      the newly created Single tuple
    • of

      static <T1, T2> Pair<T1,T2> of(T1 t1, T2 t2)
      Create a new Tuple with 2 elements
      Type Parameters:
      T1 - the first element type
      T2 - the second element type
      Parameters:
      t1 - the first element
      t2 - the second element
      Returns:
      the newly created Pair tuple
    • fromEntry

      static <T1, T2> Pair<T1,T2> fromEntry(Map.Entry<? extends T1,? extends T2> entry)
      Create a new Tuple with 2 elements from a Map Map.Entry
      Type Parameters:
      T1 - the first element type
      T2 - the second element type
      Parameters:
      entry - the map entry
      Returns:
      the newly created Pair tuple
    • of

      static <T1, T2, T3> Triple<T1,T2,T3> of(T1 t1, T2 t2, T3 t3)
      Create a new Tuple with 3 elements
      Type Parameters:
      T1 - the first element type
      T2 - the second element type
      T3 - the third element type
      Parameters:
      t1 - the first element
      t2 - the second element
      t3 - the third element
      Returns:
      the newly created Triple tuple