public class Pair<A,B>
extends Object
A pair consisting of two elements. There is no restriction on the type of the objects that may be stored.
Example:
Map<String, Object> map = new HashMap<>();
map.put("parameter", "value");
Integer number = new Integer(3);
Triple<Map<String, Object>, Integer> data = new Triple<>(map, number);
Map<String, Object> myMap = data.getFirst();
Integer myNumber = data.getSecond();| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
A |
getFirst()
Returns the first element from this pair.
|
B |
getSecond()
Returns the second element from this pair.
|
int |
hashCode() |
static <A,B> Pair<A,B> |
of(A a,
B b)
This factory allows the pair to be created using inference to obtain the generic types.
|
void |
setFirst(A a)
Sets the first element from this pair.
|
void |
setSecond(B b)
Sets the second element from this pair.
|
String |
toString()
Returns a
String representation of this pair using the format (first, second). |
public A getFirst()
public B getSecond()
public static <A,B> Pair<A,B> of(A a, B b)
a - The first element, may be nullb - The second element, may be nullpublic boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic void setFirst(A a)
public void setSecond(B b)
public String toString()
String representation of this pair using the format (first, second).toString in class ObjectString representation of this pair