Package io.karma.kommons.tuple
Interface MutablePair<L,R>
- Type Parameters:
L
- The left element type.R
- The right element type.
- All Superinterfaces:
Copyable<MutablePair<L,
,R>> Pair<L,
R>
A mutable specialization of
Pair
,
which allows setting the elements referenced by this pair instance.- Since:
- 11/08/2022
-
Method Summary
Modifier and TypeMethodDescriptionCreates a newPair
<MutablePair
,MutablePair
> containing references to the same left and right object this pair instance is referencing.default MutablePair
<L, R> Creates a newMutablePair
<Pair
,Pair
> containing references to the same left and right object this pair instance is referencing.static <L,
R> MutablePair <L, R> of
(L left, R right) Creates a new mutable pair of the given elements.void
Sets the reference to the left element.void
Sets the reference to the right element.
-
Method Details
-
of
Creates a new mutable pair of the given elements.- Type Parameters:
L
- The left element type.R
- The right element type.- Parameters:
left
- The left element or null.right
- The right element or null.- Returns:
- A new
MutablePair
<MutablePair
,MutablePair
> containing references to the given element(s).
-
setLeft
Sets the reference to the left element.- Parameters:
left
- The new left element reference or null.
-
setRight
Sets the reference to the right element.- Parameters:
right
- The new right element reference or null.
-
immutableCopy
Creates a newPair
<MutablePair
,MutablePair
> containing references to the same left and right object this pair instance is referencing.- Returns:
- A new
Pair
<MutablePair
,MutablePair
> referencing the same elements as this pair instance.
-
mutableCopy
Description copied from interface:Pair
Creates a newMutablePair
<Pair
,Pair
> containing references to the same left and right object this pair instance is referencing.- Specified by:
mutableCopy
in interfacePair<L,
R> - Returns:
- A new
MutablePair
<Pair
,Pair
> referencing the same elements as this pair instance.
-