Class Tuple2<L,R>

java.lang.Object
io.smallrye.mutiny.tuples.Tuple2<L,R>
Type Parameters:
L - The type of the first item
R - The type of the second item
All Implemented Interfaces:
Tuple, Iterable<Object>
Direct Known Subclasses:
Tuple3

public class Tuple2<L,R> extends Object implements Tuple
A tuple containing two items.
  • Constructor Details

    • Tuple2

      protected Tuple2(L left, R right)
  • Method Details

    • of

      public static <L, R> Tuple2<L,R> of(L l, R r)
    • getItem1

      public L getItem1()
      Gets the first item.
      Returns:
      The first item, can be null
    • getItem2

      public R getItem2()
      Gets the second item.
      Returns:
      The second item, can be null
    • mapItem1

      public <T> Tuple2<T,R> mapItem1(Function<L,T> mapper)
      Applies a mapper function to the left (item1) part of this Tuple2 to produce a new Tuple2. The right part (item2) is not modified.
      Type Parameters:
      T - the new type for the left item
      Parameters:
      mapper - the mapping Function for the left item
      Returns:
      the new Tuple2
    • mapItem2

      public <T> Tuple2<L,T> mapItem2(Function<R,T> mapper)
      Applies a mapper function to the right part (item2) of this Tuple2 to produce a new Tuple2. The left (item1) part is not modified.
      Type Parameters:
      T - the new type for the right item
      Parameters:
      mapper - the mapping Function for the right item
      Returns:
      the new Tuple2
    • nth

      public Object nth(int index)
      Description copied from interface: Tuple
      Get the item stored at the given index.
      Specified by:
      nth in interface Tuple
      Parameters:
      index - The index of the item to retrieve.
      Returns:
      The item, can be null
    • assertIndexInBounds

      protected void assertIndexInBounds(int index)
    • asList

      public List<Object> asList()
      Description copied from interface: Tuple
      Gets a List of Objects containing the items composing this Tuple
      Specified by:
      asList in interface Tuple
      Returns:
      A list containing the item of the tuple.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • size

      public int size()
      Specified by:
      size in interface Tuple
      Returns:
      the number of items stored in the Tuple
    • toString

      public String toString()
      Overrides:
      toString in class Object