public class Pair<A,B>
extends Object
An immutable 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.
|
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 null
b
- The second element, may be null
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
String
representation of this pair using the format (first, second).toString
in class Object
String
representation of this pair