Class Tuple2<L,​R>

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

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

      Constructors 
      Modifier Constructor Description
      protected Tuple2​(L left, R right)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<java.lang.Object> asList()
      Gets a List of Objects containing the items composing this Tuple
      protected void assertIndexInBounds​(int index)  
      boolean equals​(java.lang.Object o)  
      L getItem1()
      Gets the first item.
      R getItem2()
      Gets the second item.
      int hashCode()  
      <T> Tuple2<T,​R> mapItem1​(java.util.function.Function<L,​T> mapper)
      Applies a mapper function to the left (item1) part of this Tuple2 to produce a new Tuple2.
      <T> Tuple2<L,​T> mapItem2​(java.util.function.Function<R,​T> mapper)
      Applies a mapper function to the right part (item2) of this Tuple2 to produce a new Tuple2.
      java.lang.Object nth​(int index)
      Get the item stored at the given index.
      static <L,​R>
      Tuple2<L,​R>
      of​(L l, R r)  
      int size()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface io.smallrye.mutiny.tuples.Tuple

        iterator
    • Constructor Detail

      • Tuple2

        protected Tuple2​(L left,
                         R right)
    • Method Detail

      • 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​(java.util.function.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​(java.util.function.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 java.lang.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 java.util.List<java.lang.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​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object