Class Holder<T>

java.lang.Object
org.eclipse.net4j.util.concurrent.Holder<T>
All Implemented Interfaces:
Consumer<T>, Supplier<T>

public final class Holder<T> extends Object implements Consumer<T>, Supplier<T>
A simple holder for a single element that implements Consumer and Supplier.

This class is not thread-safe.

Since:
3.16
Author:
Eike Stepper
  • Constructor Details

    • Holder

      public Holder()
    • Holder

      public Holder(T element)
    • Holder

      public Holder(Supplier<T> creator)
      Since:
      3.29
    • Holder

      public Holder(Supplier<T> creator, T unset)
      Since:
      3.29
  • Method Details

    • isSet

      public boolean isSet()
      Since:
      3.29
    • handleIfSet

      public T handleIfSet(Consumer<T> consumer)
      Since:
      3.29
    • getIfSet

      public T getIfSet()
      Since:
      3.29
    • get

      public T get()
      Specified by:
      get in interface Supplier<T>
    • set

      public T set(T element)
    • accept

      public void accept(T element)
      Specified by:
      accept in interface Consumer<T>