-
- All Implemented Interfaces:
-
java.io.Serializable,java.lang.Comparable,java.util.Map.Entry
public final class ImmutablePair<L, R> extends Pair<L, R>
An immutable pair consisting of two
{@code 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
{@code final}, so a subclass could add undesirable behaviour.#ThreadSafe# if the objects are threadsafe
-
-
Constructor Summary
Constructors Constructor Description ImmutablePair(L left, R right)Create a new pair instance.
-
Method Summary
Modifier and Type Method Description LgetLeft()Gets the left element from this pair. RgetRight()Gets the right element from this pair. static <L, R> ImmutablePair<L, R>of(L left, R right)Obtains an immutable pair of from two objects inferring the generic types. RsetValue(R value)Throws {@code UnsupportedOperationException}.-
Methods inherited from class external.org.apache.commons.lang3.tuple.Pair
compareTo, equals, getKey, getValue, hashCode, of, toString, toString -
Methods inherited from class java.util.Map.Entry
comparingByKey, comparingByValue, getKey, getValue, setValue -
Methods inherited from class java.lang.Comparable
compareTo -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getLeft
L getLeft()
Gets the left element from this pair.
When treated as a key-value pair, this is the key.
-
getRight
R getRight()
Gets the right element from this pair.
When treated as a key-value pair, this is the value.
-
of
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 toobtain the generic types.
- Parameters:
left- the left element, may be nullright- the right element, may be null
-
-
-
-