Class MutableObject<T>

java.lang.Object
org.apache.commons.lang3.mutable.MutableObject<T>
Type Parameters:
T - the type to set and get.
All Implemented Interfaces:
Serializable, Supplier<T>, Mutable<T>

public class MutableObject<T> extends Object implements Mutable<T>, Serializable
A mutable Object wrapper.

This class was created before the introduction of AtomicReference.

Since:
2.1
See Also:
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    Constructs a new MutableObject with the default value of null.
    Constructs a new MutableObject with the specified value.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    boolean
    Compares this object against the specified object.
    Deprecated.
    int
    Returns the value's hash code or 0 if the value is null.
    void
    setValue(T value)
    Sets the value.
    Returns the String value of this mutable.

    Methods inherited from class java.lang.Object Link icon

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.commons.lang3.mutable.Mutable Link icon

    get
  • Constructor Details Link icon

    • MutableObject Link icon

      public MutableObject()
      Constructs a new MutableObject with the default value of null.
    • MutableObject Link icon

      public MutableObject(T value)
      Constructs a new MutableObject with the specified value.
      Parameters:
      value - the initial value to store.
  • Method Details Link icon

    • equals Link icon

      public boolean equals(Object obj)
      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 MutableObject 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.
    • getValue Link icon

      Deprecated.
      Gets the value.
      Specified by:
      getValue in interface Mutable<T>
      Returns:
      the value, may be null.
    • hashCode Link icon

      public int hashCode()
      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.
    • setValue Link icon

      public void setValue(T value)
      Sets the value.
      Specified by:
      setValue in interface Mutable<T>
      Parameters:
      value - the value to set.
    • toString Link icon

      public String toString()
      Returns the String value of this mutable.
      Overrides:
      toString in class Object
      Returns:
      the mutable value as a string.