Interface Pair<L,R>

Type Parameters:
L - The left element type.
R - The right element type.
All Known Subinterfaces:
MutablePair<L,R>

@API(status=STABLE) public interface Pair<L,R>
A simple pair tuple type which can hold two objects.
Since:
02/02/2022
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieves the left element of this pair instance.
    Retrieves the right element of this pair instance.
    Creates a new MutablePair<Pair, Pair> containing references to the same left and right object this pair instance is referencing.
    static <L, R> Pair<L,R>
    of(Map.Entry<L,R> entry)
    Creates a new immutable pair from the given Map.Entry.
    static <L, R> Pair<L,R>
    of(L left, R right)
    Creates a new immutable pair of the given elements.
    default Map.Entry<L,R>
    Creates a new, mutable Map.Entry from the elements referenced by this pair instance.
  • Method Details

    • of

      static <L, R> Pair<L,R> of(@Nullable L left, @Nullable R right)
      Creates a new immutable pair of the given elements.
      Type Parameters:
      L - The left element type.
      R - The right element type.
      Parameters:
      left - The left element or null.
      right - The right element or null.
      Returns:
      A new Pair<Pair, Pair> containing references to the given element(s).
    • of

      static <L, R> Pair<L,R> of(Map.Entry<L,R> entry)
      Creates a new immutable pair from the given Map.Entry.
      Type Parameters:
      L - The left element type.
      R - The right element type.
      Parameters:
      entry - The entry to create the new pair from, where K becomes Pair and V becomes Pair.
      Returns:
      A new Pair<Pair, Pair> containing references to the given element(s).
    • getLeft

      L getLeft()
      Retrieves the left element of this pair instance.
      Returns:
      The left element referenced by this pair instance.
    • getRight

      R getRight()
      Retrieves the right element of this pair instance.
      Returns:
      The right element referenced by this pair instance.
    • mutableCopy

      MutablePair<L,R> mutableCopy()
      Creates a new MutablePair<Pair, Pair> containing references to the same left and right object this pair instance is referencing.
      Returns:
      A new MutablePair<Pair, Pair> referencing the same elements as this pair instance.
    • toEntry

      default Map.Entry<L,R> toEntry()
      Creates a new, mutable Map.Entry from the elements referenced by this pair instance.
      Returns:
      A new Map.Entry instance which references the same elements as this pair instance.