Top Description Fields Constructors Methods
org.apache.commons.lang3.tuple

public Class MutablePair<L, R>

extends Pair<L, R>
Class Inheritance
Type Parameters
<L>
the left element type.
<R>
the right element type.
Imports
java.util.Map, .Objects

A mutable pair consisting of two Object elements.

Not #ThreadSafe#

Since
3.0

Field Summary

Modifier and TypeField and Description
public static final MutablePair<?, ?>[]
public L
left

Left object.

public R
right

Right object.

private static final long

Constructor Summary

AccessConstructor and Description
public
MutablePair()

Create a new pair instance of two nulls.

public
MutablePair(final L
the left value, may be null.
left
,
final R
the right value, may be null.
right
)

Create a new pair instance.

Method Summary

Modifier and TypeMethod and Description
public static <
the left element type.
L
,
the right element type.
R
>
MutablePair<L, R>[]

Returns:

the empty array singleton that can be assigned without compiler warning.
emptyArray
()

Hides org.apache.commons.lang3.tuple.Pair.emptyArray.

Returns the empty array singleton that can be assigned without compiler warning.

public L
getLeft()

Implements abstract org.apache.commons.lang3.tuple.Pair.getLeft.

Gets the left element from this pair.

public R
getRight()

Implements abstract org.apache.commons.lang3.tuple.Pair.getRight.

Gets the right element from this pair.

public static <
the left element type.
L
,
the right element type.
R
>
MutablePair<L, R>

Returns:

a mutable pair formed from the two parameters, not null.
of
(final L
the left element, may be null.
left
,
final R
the right element, may be null.
right
)

Hides org.apache.commons.lang3.tuple.Pair.of.

Creates a mutable pair of two objects inferring the generic types.

public static <
the left element type.
L
,
the right element type.
R
>
MutablePair<L, R>

Returns:

a mutable pair formed from the map entry.
of
(final Map.Entry<L, R>
the existing map entry.
pair
)

Hides org.apache.commons.lang3.tuple.Pair.of.

Creates a mutable pair from a map entry.

public static <
the left element type.
L
,
the right element type.
R
>
MutablePair<L, R>

Returns:

a mutable pair formed from the two parameters, not null.
ofNonNull
(final L
the left element, may not be null.
left
,
final R
the right element, may not be null.
right
)

Hides org.apache.commons.lang3.tuple.Pair.ofNonNull.

Creates a mutable pair of two non-null objects inferring the generic types.

public static <
the left element type
L
,
the right element type
R
>
MutablePair<L, R>

Returns:

a mutable pair formed from the map entry
ofNonNull
(final Map.Entry<L, R>
the existing map entry.
pair
)

Creates a mutable pair from a map entry.

public void
setLeft(final L
the new value of the left element, may be null.
left
)

Sets the left element of the pair.

public void
setRight(final R
the new value of the right element, may be null.
right
)

Sets the right element of the pair.

public R

Returns:

the old value for the right element.
setValue
(final R
the right value to set, not null.
value
)

Implements java.util.Map.Entry.setValue.

Sets the Map.Entry value.

Inherited from org.apache.commons.lang3.tuple.Pair:
acceptapplycompareToequalsgetKeygetValuehashCodetoStringtoString

Field Detail

EMPTY_ARRAYback to summary
public static final MutablePair<?, ?>[] EMPTY_ARRAY

Hides org.apache.commons.lang3.tuple.Pair.EMPTY_ARRAY.

An empty array.

Consider using emptyArray() to avoid generics warnings.

Since
3.10
leftback to summary
public L left

Left object.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.lang3.tuple.Pair.serialVersionUID.

Serialization version

Constructor Detail

MutablePairback to summary
public MutablePair()

Create a new pair instance of two nulls.

MutablePairback to summary
public MutablePair(final L left, final R right)

Create a new pair instance.

Parameters
left:L

the left value, may be null.

right:R

the right value, may be null.

Method Detail

emptyArrayback to summary
public static <L, R> MutablePair<L, R>[] emptyArray()

Hides org.apache.commons.lang3.tuple.Pair.emptyArray.

Returns the empty array singleton that can be assigned without compiler warning.

Parameters
<L>
the left element type.
<R>
the right element type.
Returns:MutablePair<L, R>[]

the empty array singleton that can be assigned without compiler warning.

Annotations
@SuppressWarnings:unchecked
Since
3.10
getLeftback to summary
public L getLeft()

Implements abstract org.apache.commons.lang3.tuple.Pair.getLeft.

Doc from org.apache.commons.lang3.tuple.Pair.getLeft.

Gets the left element from this pair.

When treated as a key-value pair, this is the key.

Annotations
@Override
getRightback to summary
public R getRight()

Implements abstract org.apache.commons.lang3.tuple.Pair.getRight.

Doc from org.apache.commons.lang3.tuple.Pair.getRight.

Gets the right element from this pair.

When treated as a key-value pair, this is the value.

Annotations
@Override
ofback to summary
public static <L, R> MutablePair<L, R> of(final L left, final R right)

Hides org.apache.commons.lang3.tuple.Pair.of.

Creates a mutable pair of two objects inferring the generic types.

Parameters
<L>
the left element type.
<R>
the right element type.
left:L

the left element, may be null.

right:R

the right element, may be null.

Returns:MutablePair<L, R>

a mutable pair formed from the two parameters, not null.

ofback to summary
public static <L, R> MutablePair<L, R> of(final Map.Entry<L, R> pair)

Hides org.apache.commons.lang3.tuple.Pair.of.

Creates a mutable pair from a map entry.

Parameters
<L>
the left element type.
<R>
the right element type.
pair:Map.Entry<L, R>

the existing map entry.

Returns:MutablePair<L, R>

a mutable pair formed from the map entry.

ofNonNullback to summary
public static <L, R> MutablePair<L, R> ofNonNull(final L left, final R right)

Hides org.apache.commons.lang3.tuple.Pair.ofNonNull.

Creates a mutable pair of two non-null objects inferring the generic types.

Parameters
<L>
the left element type.
<R>
the right element type.
left:L

the left element, may not be null.

right:R

the right element, may not be null.

Returns:MutablePair<L, R>

a mutable pair formed from the two parameters, not null.

Exceptions
NullPointerException:
if any input is null.
Since
3.13.0
ofNonNullback to summary
public static <L, R> MutablePair<L, R> ofNonNull(final Map.Entry<L, R> pair)

Creates a mutable pair from a map entry.

Parameters
<L>
the left element type
<R>
the right element type
pair:Map.Entry<L, R>

the existing map entry.

Returns:MutablePair<L, R>

a mutable pair formed from the map entry

Exceptions
NullPointerException:
if the pair is null.
Since
3.20
setLeftback to summary
public void setLeft(final L left)

Sets the left element of the pair.

Parameters
left:L

the new value of the left element, may be null.

setRightback to summary
public void setRight(final R right)

Sets the right element of the pair.

Parameters
right:R

the new value of the right element, may be null.

setValueback to summary
public R setValue(final R value)

Implements java.util.Map.Entry.setValue.

Sets the Map.Entry value. This sets the right element of the pair.

Parameters
value:R

the right value to set, not null.

Returns:R

the old value for the right element.

Annotations
@Override