Package w.util.pair

Interface MutablePair<L,R>

All Superinterfaces:
Cloneable, Pair<L,R>

public interface MutablePair<L,R> extends Pair<L,R>
Мутабельная пара значений, можно изменять левое и правое значение.

Недостаток этой реализации от обычной иммутабельной пары в том, что hashCode не кешируется.

Author:
whilein
  • Method Details

    • of

      @NotNull static <L, R> @NotNull MutablePair<L,R> of(L left, R right)
    • of

      @NotNull static <L, R> @NotNull MutablePair<L,R> of(@NotNull Map.Entry<L,R> entry)
    • setLeft

      void setLeft(L value)
    • setRight

      void setRight(R value)
    • withLeft

      @NotNull <L1> @NotNull MutablePair<L1,R> withLeft(L1 newValue)
      Specified by:
      withLeft in interface Pair<L,R>
    • withRight

      @NotNull <R1> @NotNull MutablePair<L,R1> withRight(R1 newValue)
      Specified by:
      withRight in interface Pair<L,R>
    • clone

      @NotNull @NotNull MutablePair<L,R> clone()
      Description copied from interface: Pair
      Склонировать пару.
      Specified by:
      clone in interface Pair<L,R>
      Returns:
      новая склонированая пара
    • deepClone

      @NotNull @NotNull MutablePair<L,R> deepClone()
      Description copied from interface: Pair
      Склонировать пару.

      Также, в отличие от Pair.clone(), клонируется L и R, если они наследуют Cloneable.

      Specified by:
      deepClone in interface Pair<L,R>
      Returns:
      новая склонированая пара