Class Pair<L,​R>

  • Type Parameters:
    L - the Generic Type of the left element of this Pair
    R - the Generic Type of right element of this Pair
    All Implemented Interfaces:
    Serializable

    @ParametersAreNonnullByDefault
    public class Pair<L,​R>
    extends Object
    implements Serializable
    A simple, immutable Tuple with 2 elements: left and right.
    See Also:
    Serialized Form
    • Field Detail

      • left

        public final L left
      • right

        public final R right
    • Method Detail

      • of

        @Nonnull
        public static <L,​R> Pair<L,​R> of​(L left,
                                                     R right)
        Creates a new Pair with values left and right
        Type Parameters:
        L - the Class of the left value
        R - the Class of the right value
        Parameters:
        left - the left value
        right - the right value
        Returns:
        a new Pair
      • hashCode

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

        public Pair<R,​L> swap()
        Creates a new Pair by swapping the elements left and right
        Returns:
        a new Pair with inverted values and Generic Types