Package org.aoju.bus.core.lang.tuple
Class ImmutablePair<L,R>
java.lang.Object
org.aoju.bus.core.lang.tuple.Pair<L,R>
org.aoju.bus.core.lang.tuple.ImmutablePair<L,R>
- Type Parameters:
L- the left element typeR- the right element type
- All Implemented Interfaces:
Serializable,Comparable<Pair<L,,R>> Map.Entry<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
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetLeft()从这一对中获取左元素getRight()从这一对中获取右元素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.ThrowsUnsupportedOperationException.
-
Field Details
-
left
Left object -
right
Right object
-
-
Constructor Details
-
ImmutablePair
-
-
Method Details
-
nullPair
Returns an immutable pair of nulls.- Type Parameters:
L- the left element of this pair. Value isnull.R- the right element of this pair. Value isnull.- Returns:
- an immutable pair of nulls.
-
of
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.
- Type Parameters:
L- the left element typeR- the right element type- Parameters:
left- the left element, may be nullright- the right element, may be null- Returns:
- a pair formed from the two parameters, not null
-
getLeft
-
getRight
-
setValue
Throws
UnsupportedOperationException.This pair is immutable, so this operation is not supported.
- Parameters:
value- the value to set- Returns:
- never
- Throws:
UnsupportedOperationException- as this operation is not supported
-