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.
|
void |
setFirst(A f)
Set the first element of the pair.
|
void |
setSecond(B s)
Set the second element of the pair.
|
String |
toString() |
protected A first
protected B second
public A getFirst()
public B getSecond()
public void setFirst(A f)
f
- the element to be assigned.public void setSecond(B s)
s
- the element to be assigned.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 © 2019. All rights reserved.