Class Holder<E>

  • Type Parameters:
    E - Element type

    public class Holder<E>
    extends 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.

    • 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.
      • empty

        public static <E> Holder<@Nullable E> empty()
        Creates a holder containing null.