L
- the left element typeR
- the right element typepublic final class ImmutablePair<L,R> extends Pair<L,R>
An immutable pair consisting of two Object
elements.
Although the implementation is immutable, there is no restriction on the objects
that may be stored. If mutable objects are stored in the pair, then the pair
itself effectively becomes mutable. The class is also final
, so a subclass
can not add undesirable behaviour.
#ThreadSafe# if both paired objects are thread-safe
Modifier and Type | Field and Description |
---|---|
L |
left
Left object
|
R |
right
Right object
|
Constructor and Description |
---|
ImmutablePair(L left,
R right)
Create a new pair instance.
|
Modifier and Type | Method and Description |
---|---|
L |
getLeft()
Gets the left element from this pair.
|
R |
getRight()
Gets the right element from this pair.
|
static <L,R> ImmutablePair<L,R> |
nullPair()
Returns an immutable pair of nulls.
|
static <L,R> ImmutablePair<L,R> |
of(L left,
R right)
Obtains an immutable pair of two objects inferring the generic types.
|
R |
setValue(R value)
Throws
UnsupportedOperationException . |
public static <L,R> ImmutablePair<L,R> nullPair()
L
- the left element of this pair. Value is null
.R
- the right element of this pair. Value is null
.public static <L,R> ImmutablePair<L,R> of(L left, R right)
Obtains an immutable 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 R getRight()
Gets the right element from this pair.
When treated as a key-value pair, this is the value.
Copyright © 2010 - 2020 Adobe. All Rights Reserved