Class MutableObject<T>

  • All Implemented Interfaces:
    Mutable<T>

    public class MutableObject<T>
    extends Object
    implements Mutable<T>
    * Mutable class wrapper for objects. Mutable classes are useful in lambda expressions or anonymous classes which want to alter the content of a variable but are limited to final or effective final variables. * Be aware that the hashcode changes if the value is updated resulting in the object not being retrievable in hash collections.
    Since:
    1.5.10 com.github.kilianB
    Author:
    Kilian
    • Constructor Detail

      • MutableObject

        public MutableObject()
      • MutableObject

        public MutableObject​(T initialValue)
    • Method Detail

      • getValue

        public T getValue()
        Description copied from interface: Mutable
        Get an object encapsulating the current value
        Specified by:
        getValue in interface Mutable<T>
        Returns:
        The current value as an immutable base object
      • setValue

        public void setValue​(T newValue)
        Description copied from interface: Mutable
        Set the internal field to the new value
        Specified by:
        setValue in interface Mutable<T>
        Parameters:
        newValue - the new value
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object