Top Description Methods
org.eclipse.collections.api.tuple

public Interface Pair<T1, T2>

extends Serializable, Comparable<Pair<T1, T2>>
Known Direct Subinterfaces
org.eclipse.collections.api.tuple.Twin
Imports
java.io.Serializable, java.util.Map, .Objects

A Pair 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. An instance of this interface can be created by calling Tuples.pair(Object, Object) or Tuples.twin(Object, Object).

Method Summary

Modifier and TypeMethod and Description
public T1
public T2
public default boolean
public default boolean
public void
put(Map<? super T1, ? super T2> map)

public Pair<T2, T1>
swap()

Method used to swap the elements of pair.

public Map.Entry<T1, T2>
Inherited from java.lang.Comparable:
compareTo

Method Detail

getOneback to summary
public T1 getOne()
getTwoback to summary
public T2 getTwo()
isEqualback to summary
public default boolean isEqual()
isSameback to summary
public default boolean isSame()
putback to summary
public void put(Map<? super T1, ? super T2> map)
swapback to summary
public Pair<T2, T1> swap()

Method used to swap the elements of pair.

e.g.
Pair<String, Integer> pair = Tuples.pair("One", 1);
Pair<Integer, String> swappedPair = pair.swap();
Since
6.0
toEntryback to summary
public Map.Entry<T1, T2> toEntry()