L - the left element typeR - the right element typepublic class Pair<L,R> extends Object implements Map.Entry<L,R>, Serializable
A pair consisting of two elements.
This class is an abstract implementation defining the basic API. It refers to
the elements as 'left' and 'right'. It also implements the Map.Entry
interface where the key is 'left' and the value is 'right'.
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
L |
getKey() |
L |
getLeft() |
R |
getRight() |
R |
getValue() |
int |
hashCode()
Returns a suitable hash code.
|
Pair<L,R> |
of(L left,
R right) |
void |
setLeft(L left) |
void |
setRight(R right) |
R |
setValue(R right) |
String |
toString()
Returns a String representation of this pair using the format
($left,$right). |
String |
toString(String format)
Formats the receiver using the given format.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcomparingByKey, comparingByKey, comparingByValue, comparingByValuepublic L getLeft()
public void setLeft(L left)
public R getRight()
public void setRight(R right)
public String toString()
Returns a String representation of this pair using the format
($left,$right).
public boolean equals(Object obj)
public int hashCode()
Returns a suitable hash code. The hash code follows the definition in
Map.Entry.
public String toString(String format)
Formats the receiver using the given format.
This uses Formattable to perform the formatting. Two
variables may be used to embed the left and right elements. Use
%1$s for the left element (key) and %2$s for the right
element (value). The default format used by toString() is
(%1$s,%2$s).
format - the format string, optionally containing %1$s and
%2$s, not nullCopyright © 2020. All rights reserved.