Interface Pair<T1,T2>
-
- All Superinterfaces:
java.lang.Comparable<Pair<T1,T2>>
,java.io.Serializable
- All Known Subinterfaces:
Twin<T>
public interface Pair<T1,T2> extends java.io.Serializable, java.lang.Comparable<Pair<T1,T2>>
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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description T1
getOne()
T2
getTwo()
default boolean
isEqual()
default boolean
isSame()
void
put(java.util.Map<? super T1,? super T2> map)
Pair<T2,T1>
swap()
Method used to swap the elements of pair.java.util.Map.Entry<T1,T2>
toEntry()
-
-
-
Method Detail
-
getOne
T1 getOne()
-
getTwo
T2 getTwo()
-
swap
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
-
isEqual
default boolean isEqual()
-
isSame
default boolean isSame()
-
-