L
- the left element typeR
- the right element typepublic class MutablePair<L,R> extends Pair<L,R>
A mutable pair consisting of two Object
elements.
Not #ThreadSafe#
Modifier and Type | Field and Description |
---|---|
static MutablePair<?,?>[] |
EMPTY_ARRAY
An empty array.
|
L |
left
Left object
|
R |
right
Right object
|
Constructor and Description |
---|
MutablePair()
Create a new pair instance of two nulls.
|
MutablePair(L left,
R right)
Create a new pair instance.
|
Modifier and Type | Method and Description |
---|---|
static <L,R> MutablePair<L,R>[] |
emptyArray()
Returns the empty array singleton that can be assigned without compiler warning.
|
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)
Creates a mutable pair of two objects inferring the generic types.
|
static <L,R> MutablePair<L,R> |
of(Map.Entry<L,R> pair)
Creates a mutable pair from an existing pair.
|
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. |
compareTo, equals, getKey, getValue, hashCode, toString, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
comparingByKey, comparingByKey, comparingByValue, comparingByValue
public static final MutablePair<?,?>[] EMPTY_ARRAY
Consider using emptyArray()
to avoid generics warnings.
public L left
public R right
public static <L,R> MutablePair<L,R>[] emptyArray()
L
- the left element typeR
- the right element typepublic static <L,R> MutablePair<L,R> of(L left, R right)
Creates 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 static <L,R> MutablePair<L,R> of(Map.Entry<L,R> pair)
Creates a mutable pair from an existing pair.
This factory allows the pair to be created using inference to obtain the generic types.
L
- the left element typeR
- the right element typepair
- the existing pair.public L getLeft()
Gets the left element from this pair.
When treated as a key-value pair, this is the key.
public R getRight()
Gets the right element from this pair.
When treated as a key-value pair, this is the value.
public void setLeft(L left)
left
- the new value of the left element, may be nullpublic void setRight(R right)
right
- the new value of the right element, may be nullCopyright © 2001–2021 The Apache Software Foundation. All rights reserved.