A - Class type for the first elementB - Class type for the second elementpublic class Pair<A,B>
extends java.lang.Object
A tuple 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(java.lang.Object o)
Indicates whether some other object is "equal to" this one.
|
A |
getFirst()
Returns the first element from this pair.
|
B |
getSecond()
Returns the second element from this pair.
|
int |
hashCode()
Returns a hash code value for the object.
|
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.
|
java.lang.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 - Class type for the first elementB - Class type for the second elementa - The first element, may be nullb - The second element, may be nullpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - Reference object with which to comparetrue if this object is the same as the o argument; false otherwisepublic int hashCode()
HashMap.hashCode in class java.lang.Objectpublic void setFirst(A a)
a - The first element, may be nullpublic void setSecond(B b)
b - The second element, may be nullpublic java.lang.String toString()
String representation of this pair using the format (first, second).toString in class java.lang.ObjectString representation of this pair