Package io.karma.kommons.tuple
Interface Pair<L,R>
- Type Parameters:
L
- The left element type.R
- The right element type.
- All Known Subinterfaces:
MutablePair<L,
R>
@API(status=STABLE)
public interface Pair<L,R>
A simple pair tuple type which can hold two objects.
- Since:
- 02/02/2022
-
Method Summary
Modifier and TypeMethodDescriptiongetLeft()
Retrieves the left element of this pair instance.getRight()
Retrieves the right element of this pair instance.Creates a newMutablePair
<Pair
,Pair
> containing references to the same left and right object this pair instance is referencing.static <L,
R> Pair <L, R> Creates a new immutable pair from the givenMap.Entry
.static <L,
R> Pair <L, R> of
(L left, R right) Creates a new immutable pair of the given elements.toEntry()
Creates a new, mutableMap.Entry
from the elements referenced by this pair instance.
-
Method Details
-
of
Creates a new immutable pair of the given elements. -
of
Creates a new immutable pair from the givenMap.Entry
. -
getLeft
L getLeft()Retrieves the left element of this pair instance.- Returns:
- The left element referenced by this pair instance.
-
getRight
R getRight()Retrieves the right element of this pair instance.- Returns:
- The right element referenced by this pair instance.
-
mutableCopy
MutablePair<L,R> mutableCopy()Creates a newMutablePair
<Pair
,Pair
> containing references to the same left and right object this pair instance is referencing.- Returns:
- A new
MutablePair
<Pair
,Pair
> referencing the same elements as this pair instance.
-
toEntry
Creates a new, mutableMap.Entry
from the elements referenced by this pair instance.- Returns:
- A new
Map.Entry
instance which references the same elements as this pair instance.
-