Interface MutablePair<L,R>

Type Parameters:
L - The left element type.
R - The right element type.
All Superinterfaces:
Copyable<MutablePair<L,R>>, Pair<L,R>

@API(status=STABLE) public interface MutablePair<L,R> extends Pair<L,R>, Copyable<MutablePair<L,R>>
A mutable specialization of Pair, which allows setting the elements referenced by this pair instance.
Since:
11/08/2022
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new Pair<MutablePair, MutablePair> containing references to the same left and right object this pair instance is referencing.
    default MutablePair<L,R>
    Creates a new MutablePair<Pair, Pair> containing references to the same left and right object this pair instance is referencing.
    static <L, R> MutablePair<L,R>
    of(L left, R right)
    Creates a new mutable pair of the given elements.
    void
    setLeft(L left)
    Sets the reference to the left element.
    void
    setRight(R right)
    Sets the reference to the right element.

    Methods inherited from interface io.karma.kommons.util.Copyable

    copy

    Methods inherited from interface io.karma.kommons.tuple.Pair

    getLeft, getRight, toEntry
  • Method Details

    • of

      static <L, R> MutablePair<L,R> of(@Nullable L left, @Nullable R right)
      Creates a new mutable 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 MutablePair<MutablePair, MutablePair> containing references to the given element(s).
    • setLeft

      void setLeft(@Nullable L left)
      Sets the reference to the left element.
      Parameters:
      left - The new left element reference or null.
    • setRight

      void setRight(@Nullable R right)
      Sets the reference to the right element.
      Parameters:
      right - The new right element reference or null.
    • immutableCopy

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

      default MutablePair<L,R> mutableCopy()
      Description copied from interface: Pair
      Creates a new MutablePair<Pair, Pair> containing references to the same left and right object this pair instance is referencing.
      Specified by:
      mutableCopy in interface Pair<L,R>
      Returns:
      A new MutablePair<Pair, Pair> referencing the same elements as this pair instance.