L
- the left element typeR
- the right element typepublic class MutablePair<L,R> extends Pair<L,R>
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(java.util.Map.Entry<L,R> pair)
Creates a mutable pair from a map entry.
|
static <L,R> MutablePair<L,R> |
ofNonNull(L left,
R right)
Creates a mutable pair of two non-null 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 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)
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(java.util.Map.Entry<L,R> 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 map entry.public static <L,R> MutablePair<L,R> ofNonNull(L left, R right)
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 not be nullright
- the right element, may not be nulljava.lang.NullPointerException
- if any input is nullpublic L getLeft()
When treated as a key-value pair, this is the key.
public R getRight()
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 © 2010 - 2023 Adobe. All Rights Reserved