Class MutableObject<T>

  • Type Parameters:
    T - the type to set and get
    All Implemented Interfaces:
    java.io.Serializable, Mutable<T>

    public class MutableObject<T>
    extends java.lang.Object
    implements Mutable<T>, java.io.Serializable
    A mutable Object wrapper.
    Since:
    2.1
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      MutableObject()
      Constructs a new MutableObject with the default value of null.
      MutableObject​(T value)
      Constructs a new MutableObject with the specified value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      Compares this object against the specified object.
      T getValue()
      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.
      java.lang.String toString()
      Returns the String value of this mutable.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • MutableObject

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

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

      • getValue

        public T getValue()
        Gets the value.
        Specified by:
        getValue in interface Mutable<T>
        Returns:
        the value, may be null
      • setValue

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

        public boolean equals​(java.lang.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 T value as this object.

        Overrides:
        equals in class java.lang.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.
      • hashCode

        public int hashCode()
        Returns the value's hash code or 0 if the value is null.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the value's hash code or 0 if the value is null.
      • toString

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