Package w.util.pair

Interface UnorderedPair<L,R>

All Superinterfaces:
Cloneable, Pair<L,R>

public interface UnorderedPair<L,R> extends Pair<L,R>
Иммутабельная пара значений.

В реализации Object.hashCode() возвращает одно и то же число, когда L и R перепутаны местами. Т.е хешкод пары (A, B) равен хешкоду пары (B, A).

Object.equals(Object) также возвращает true, если значения в разном порядке.

Author:
whilein
  • Field Details

  • Method Details

    • of

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

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

      @NotNull @NotNull UnorderedPair<R,L> reverse()
    • getOrder

      int getOrder()
      Returns:
      LEFT_GREATER или RIGHT_GREATER
    • getGreater

      @NotNull @NotNull Object getGreater()
    • getLower

      @NotNull @NotNull Object getLower()
    • withLeft

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

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

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

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

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

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