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.

Parameters:

<T> – The type to set and get.

See also:

AtomicReference

Since:

2.1

Constructors

MutableObject()

Constructs a new MutableObject with the default value of null.

MutableObject(Object)

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

equals(Object)

Compares this object against the specified object.

getValue()

Deprecated. Gets the value.

hashCode()

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

setValue(Object)

Sets the value.

toString()

Returns the String value of this mutable.

@Override 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.

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 @Override public T getValue()[source]

Deprecated: Use #get().

Gets the value.

Returns:

The value, may be null.

@Override public int hashCode()[source]

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

Returns:

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

@Override public void setValue(T value)[source]

Sets the value.

Parameters:

value – The value to set.

@Override public String toString()[source]

Returns the String value of this mutable.

Returns:

The mutable value as a string.