L
- the left element typeR
- the right element typeSerializable
, Comparable<Pair<L,R>>
, Map.Entry<L,R>
public class MutablePair<L,R> extends Pair<L,R>
A mutable pair consisting of two Object
elements.
Not #ThreadSafe#
Constructor | Description |
---|---|
MutablePair() |
Create a new pair instance of two nulls.
|
MutablePair(L left,
R right) |
Create a new pair instance.
|
Modifier and Type | Method | Description |
---|---|---|
L |
getLeft() |
Gets the left element from this pair.
|
R |
getRight() |
Gets the right element from this pair.
|
static <L,R> MutablePair<L,R> |
of(L left,
R right) |
Obtains a mutable pair of two objects inferring the generic types.
|
void |
setLeft(L left) |
Sets the left element of the pair.
|
void |
setRight(R right) |
Sets the right element of the pair.
|
R |
setValue(R value) |
Sets the
Map.Entry value. |
public static <L,R> MutablePair<L,R> of(L left, R right)
Obtains a mutable pair of two objects inferring the generic types.
This factory allows the pair to be created using inference to obtain the generic types.
L
- the left element typeR
- the right element typeleft
- the left element, may be nullright
- the right element, may be nullpublic L getLeft()
Gets the left element from this pair.
When treated as a key-value pair, this is the key.
public void setLeft(L left)
left
- the new value of the left element, may be nullpublic R getRight()
Gets the right element from this pair.
When treated as a key-value pair, this is the value.
public void setRight(R right)
right
- the new value of the right element, may be nullCopyright © 2001–2018. All rights reserved.