Class MemoizingSupplier<T>

java.lang.Object
aQute.lib.memoize.MemoizingSupplier<T>
All Implemented Interfaces:
Memoize<T>, Supplier<T>

class MemoizingSupplier<T> extends Object implements Memoize<T>
The object can exist in one of two states:
  • initial which means get has not been called and memoized holds the wrapped supplier. From this state, the object can transition to open.
  • open which means memoized is the value from the wrapped supplier. This is the terminal state.
  • Field Details

    • initial

      private volatile boolean initial
    • memoized

      private Object memoized
  • Constructor Details

    • MemoizingSupplier

      MemoizingSupplier(Supplier<? extends T> supplier)
  • Method Details

    • get

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

      public T peek()
      Description copied from interface: Memoize
      Peek the memoized value, if any.

      This method will not result in a call to the source supplier.

      Specified by:
      peek in interface Memoize<T>
      Returns:
      The value if a value is memoized; otherwise null.