Class Holder<E>

  • Type Parameters:
    E - Element type

    public class Holder<E>
    extends java.lang.Object
    A mutable slot that can contain one object.

    A holder is useful for implementing OUT or IN-OUT parameters.

    It is possible to sub-class to receive events on get or set.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private E e  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Holder​(E e)
      Creates a Holder containing a given value.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      E get()
      Gets the value.
      static <E> Holder<E> of​(E e)
      Creates a holder containing a given value.
      void set​(E e)
      Sets the value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • e

        private E e
    • Constructor Detail

      • Holder

        protected Holder​(E e)
        Creates a Holder containing a given value.

        Call this method from a derived constructor or via the of(E) method.

    • Method Detail

      • set

        public void set​(E e)
        Sets the value.
      • get

        public E get()
        Gets the value.
      • of

        public static <E> Holder<E> of​(E e)
        Creates a holder containing a given value.