A
- the first element typeB
- the second element typepublic class Pair<A,B> extends Object implements Serializable
Although the instances of this class are immutable, it is impossible to ensure that the references passed to the constructor will not be modified by the caller.
Modifier and Type | Field and Description |
---|---|
protected A |
first
The first pair element
|
protected B |
second
The second pair element
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
A |
getFirst()
Get the first element of the pair
|
B |
getSecond()
Get the second element of the pair
|
<E> boolean |
hasElement(E e)
Assess if this pair contains an element.
|
int |
hashCode() |
static <A,B> Pair<A,B> |
of(A a,
B b)
Creates new pair of elements pulling of the necessity to provide corresponding types of the
elements supplied.
|
String |
toString() |
protected final A first
protected final B second
public A getFirst()
public B getSecond()
public <E> boolean hasElement(E e)
E
- the element typee
- The element in questionpublic static <A,B> Pair<A,B> of(A a, B b)
A
- the first element typeB
- the second element typea
- first elementb
- second elementCopyright © 2018. All rights reserved.