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

public Class MutableObject<T>

extends Object
implements Mutable<T>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.lang3.mutable.Mutable, java.util.function.Supplier
Type Parameters
<T>
the type to set and get.
Imports
java.io.Serializable, java.util.Objects, java.util.concurrent.atomic.AtomicReference

A mutable Object wrapper.

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

Since
2.1
See Also
AtomicReference

Field Summary

Modifier and TypeField and Description
private static final long
serialVersionUID

Required for serialization support.

private T
value

The mutable value.

Constructor Summary

AccessConstructor and Description
public
MutableObject()

Constructs a new MutableObject with the default value of null.

public
MutableObject(final T
the initial value to store.
value
)

Constructs a new MutableObject with the specified value.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the objects are the same; true if the objects have equivalent value fields; false otherwise.
equals
(final Object
the object to compare with, null returns false.
obj
)

Overrides java.lang.Object.equals.

Compares this object against the specified object.

public T

Returns:

the value, may be null.
getValue
()

Implements org.apache.commons.lang3.mutable.Mutable.getValue.

Deprecated Use get().

Gets the value.

public int

Returns:

the value's hash code or 0 if the value is null.
hashCode
()

Overrides java.lang.Object.hashCode.

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

public void
setValue(final T
the value to set.
value
)

Implements org.apache.commons.lang3.mutable.Mutable.setValue.

Sets the value.

public String

Returns:

the mutable value as a string.
toString
()

Overrides java.lang.Object.toString.

Returns the String value of this mutable.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Required for serialization support.

See Also
java.io.Serializable
valueback to summary
private T value

The mutable value.

Constructor Detail

MutableObjectback to summary
public MutableObject()

Constructs a new MutableObject with the default value of null.

MutableObjectback to summary
public MutableObject(final T value)

Constructs a new MutableObject with the specified value.

Parameters
value:T

the initial value to store.

Method Detail

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

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:Object

the object to compare with, null returns false.

Returns:boolean

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

Annotations
@Override
getValueback to summary
public T getValue()

Implements org.apache.commons.lang3.mutable.Mutable.getValue.

Deprecated

Use get().

Gets the value.

Returns:T

the value, may be null.

Annotations
@Deprecated
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

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

Returns:int

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

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

Implements org.apache.commons.lang3.mutable.Mutable.setValue.

Sets the value.

Parameters
value:T

the value to set.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the String value of this mutable.

Returns:String

the mutable value as a string.

Annotations
@Override