On this page

MutableObject

public class org.apache.commons.lang3.mutable.MutableObject<T> implements Mutable<T>, Serializable[source]

A mutable Object wrapper.

This class was created before the introduction of the java.util.concurrent.atomic package and the AtomicReference class.

Type parameters:

<T> – The type to set and get.

Since:

2.1

See also:

AtomicReference

Constructors

MutableObject()

Constructs a new MutableObject with the default value of null.

MutableObject(T value)

Constructs a new MutableObject with the specified value.

public MutableObject()[source]

Constructs a new MutableObject with the default value of null.

public MutableObject(T value)[source]

Constructs a new MutableObject with the specified value.

Parameters:

value – The initial value to store.

Methods

boolean

equals(Object obj)

Compares this object against the specified object.

T

getValue()

Deprecated. Gets the value.

int

hashCode()

Returns the value's hash code or 0 if the value is null.

void

setValue(T value)

Sets the value.

String

toString()

Returns the String value of this mutable.

public boolean equals(Object obj)[source]

Compares this object against the specified object. The result is true if and only if the argument is not null and is a MutableObject object that contains the same T value as this object.

Overrides:

equals in class Object

Parameters:

obj – The object to compare with, null returns false.

Returns:

true if the objects are the same; true if the objects have equivalent value fields; false otherwise.

@Deprecated public T getValue()[source]

Deprecated: Use Mutable.get().

Gets the value.

Specified by:

getValue in interface Mutable

Returns:

The value, may be null.

public int hashCode()[source]

Returns the value's hash code or 0 if the value is null.

Overrides:

hashCode in class Object

Returns:

The value's hash code or 0 if the value is null.

public void setValue(T value)[source]

Sets the value.

Specified by:

setValue in interface Mutable

Parameters:

value – The value to set.

public String toString()[source]

Returns the String value of this mutable.

Overrides:

toString in class Object

Returns:

The mutable value as a string.