Top Description Methods
org.apache.commons.lang3.mutable

public Interface Mutable<T>

extends Supplier<T>
Known Direct Implementers
org.apache.commons.lang3.mutable.MutableBoolean, org.apache.commons.lang3.mutable.MutableByte, org.apache.commons.lang3.mutable.MutableDouble, org.apache.commons.lang3.mutable.MutableFloat, org.apache.commons.lang3.mutable.MutableInt, org.apache.commons.lang3.mutable.MutableLong, org.apache.commons.lang3.mutable.MutableObject, org.apache.commons.lang3.mutable.MutableShort
Type Parameters
<T>
the type to wrap.
Imports
java.util.function.Supplier

Provides mutable access to a value.

Mutable is used as a generic interface to the implementations in this package.

A typical use case would be to enable a primitive or string to be passed to a method and allow that method to effectively change the value of the primitive/object. Another use case is to store a frequently changing primitive in a collection (for example a total in a map) without needing to create new Integer/Long wrapper objects.

Since
2.1

Method Summary

Modifier and TypeMethod and Description
public default T

Returns:

the stored value.
get
()

Implements java.util.function.Supplier.get.

Gets the value of this mutable.

public T

Returns:

the stored value.
getValue
()
Deprecated Use get().

Gets the value of this mutable.

public void
setValue(T
the value to store.
value
)

Sets the value of this mutable.

Method Detail

getback to summary
public default T get()

Implements java.util.function.Supplier.get.

Gets the value of this mutable.

Returns:T

the stored value.

Annotations
@Override
Since
3.18.0
getValueback to summary
public T getValue()

Deprecated

Use get().

Gets the value of this mutable.

Returns:T

the stored value.

Annotations
@Deprecated
setValueback to summary
public void setValue(T value)

Sets the value of this mutable.

Parameters
value:T

the value to store.

Exceptions
NullPointerException:
if the object is null and null is invalid.
ClassCastException:
if the type is invalid.