|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.lang3.tuple.Pair<L,R> org.apache.commons.lang3.tuple.ImmutablePair<L,R>
L
- the left element typeR
- the right element typepublic final class ImmutablePair<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 not final
, so a subclass
could add undesirable behaviour.
#ThreadSafe# if the objects are threadsafe
Field Summary | |
---|---|
L |
left
Left object |
R |
right
Right object |
Constructor Summary | |
---|---|
ImmutablePair(L left,
R right)
Create a new pair instance. |
Method Summary | ||
---|---|---|
L |
getLeft()
Gets the left element from this pair. |
|
R |
getRight()
Gets the right element from this pair. |
|
static
|
of(L left,
R right)
Obtains an immutable pair of from two objects inferring the generic types. |
|
R |
setValue(R value)
Throws UnsupportedOperationException . |
Methods inherited from class org.apache.commons.lang3.tuple.Pair |
---|
compareTo, equals, getKey, getValue, hashCode, toString, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final L left
public final R right
Constructor Detail |
---|
public ImmutablePair(L left, R right)
left
- the left value, may be nullright
- the right value, may be nullMethod Detail |
---|
public static <L,R> ImmutablePair<L,R> of(L left, R right)
Obtains an immutable pair of from 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 null
public L getLeft()
Gets the left element from this pair.
When treated as a key-value pair, this is the key.
getLeft
in class Pair<L,R>
public R getRight()
Gets the right element from this pair.
When treated as a key-value pair, this is the value.
getRight
in class Pair<L,R>
public R setValue(R value)
Throws UnsupportedOperationException
.
This pair is immutable, so this operation is not supported.
value
- the value to set
UnsupportedOperationException
- as this operation is not supported
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |