Class PairImpl<T1,T2>

java.lang.Object
org.eclipse.collections.impl.tuple.PairImpl<T1,T2>
All Implemented Interfaces:
Serializable, Comparable<Pair<T1,T2>>, Pair<T1,T2>
Direct Known Subclasses:
TwinImpl

class PairImpl<T1,T2> extends Object implements Pair<T1,T2>
A PairImpl is a container that holds two related objects. It is the equivalent of an Association in Smalltalk, or an implementation of Map.Entry in the JDK.
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • one

      private final T1 one
    • two

      private final T2 two
  • Constructor Details

    • PairImpl

      PairImpl(T1 newOne, T2 newTwo)
  • Method Details

    • getOne

      public T1 getOne()
      Specified by:
      getOne in interface Pair<T1,T2>
    • getTwo

      public T2 getTwo()
      Specified by:
      getTwo in interface Pair<T1,T2>
    • put

      public void put(Map<? super T1,? super T2> map)
      Specified by:
      put in interface Pair<T1,T2>
    • swap

      public PairImpl<T2,T1> swap()
      Description copied from interface: Pair
      Method used to swap the elements of pair.
      e.g.
       Pair<String, Integer> pair = Tuples.pair("One", 1);
       Pair<Integer, String> swappedPair = pair.swap();
       
      Specified by:
      swap in interface Pair<T1,T2>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object
    • toEntry

      public Map.Entry<T1,T2> toEntry()
      Specified by:
      toEntry in interface Pair<T1,T2>
    • compareTo

      public int compareTo(Pair<T1,T2> other)
      Specified by:
      compareTo in interface Comparable<T1>