Class Tuple

java.lang.Object
org.storynode.pigeon.tuple.Tuple
Direct Known Subclasses:
Pair, Quartet, Quintet, Triplet

public abstract class Tuple extends Object
A tuple may be defined in many ways, but simply speaking it's a finite, heterogeneous sequence of elements.
Since:
1.0.0
Author:
Andrea Coronese
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Enumerates the items in this tuple
    boolean
    equals(Object other)
    static <T1, T2> @NotNull Pair<T1,T2>
    of(T1 first, T2 second)
    Creates a Tuple of two elements
    static <T1, T2, T3>
    @NotNull Triplet<T1,T2,T3>
    of(T1 first, T2 second, T3 third)
    Creates a Tuple of three elements
    static <T1, T2, T3, T4>
    @NotNull Quartet<T1,T2,T3,T4>
    of(T1 first, T2 second, T3 third, T4 fourth)
    Creates a Tuple of four elements
    static <T1, T2, T3, T4, T5>
    @NotNull Quintet<T1,T2,T3,T4,T5>
    of(T1 first, T2 second, T3 third, T4 fourth, T5 fifth)
    Creates a Tuple of five elements

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Tuple

      public Tuple()
  • Method Details

    • of

      @Contract("_, _ -> new") @NotNull public static <T1, T2> @NotNull Pair<T1,T2> of(T1 first, T2 second)
      Creates a Tuple of two elements
      Type Parameters:
      T1 - The type of the first element
      T2 - The type of the second element
      Parameters:
      first - The first element
      second - The second element
      Returns:
      The Tuple
    • of

      @Contract("_, _, _ -> new") @NotNull public static <T1, T2, T3> @NotNull Triplet<T1,T2,T3> of(T1 first, T2 second, T3 third)
      Creates a Tuple of three elements
      Type Parameters:
      T1 - The type of the first element
      T2 - The type of the second element
      T3 - The type of the third element
      Parameters:
      first - The first element
      second - The second element
      third - The third element
      Returns:
      The [Tuple]
    • of

      @Contract("_, _, _, _ -> new") @NotNull public static <T1, T2, T3, T4> @NotNull Quartet<T1,T2,T3,T4> of(T1 first, T2 second, T3 third, T4 fourth)
      Creates a Tuple of four elements
      Type Parameters:
      T1 - The type of the first element
      T2 - The type of the second element
      T3 - The type of the third element
      T4 - The type of the fourth element
      Parameters:
      first - The first element
      second - The second element
      third - The third element
      fourth - The fourth element
      Returns:
      The Tuple
    • of

      @Contract("_, _, _, _, _ -> new") @NotNull public static <T1, T2, T3, T4, T5> @NotNull Quintet<T1,T2,T3,T4,T5> of(T1 first, T2 second, T3 third, T4 fourth, T5 fifth)
      Creates a Tuple of five elements
      Type Parameters:
      T1 - The type of the first element
      T2 - The type of the second element
      T3 - The type of the third element
      T4 - The type of the fourth element
      T5 - The type of the fifth element
      Parameters:
      first - The first element
      second - The second element
      third - The third element
      fourth - The fourth element
      fifth - The fifth element
      Returns:
      The [Tuple]
    • enumerate

      public Iterable<Pair<Object,Integer>> enumerate()
      Enumerates the items in this tuple
      Returns:
      An Iterable of pairs each containing an item and its index
    • equals

      public boolean equals(Object other)

      Checks whether the other instance is equal to this

      Overrides:
      equals in class Object