Class RefreshingMemoizingSupplier<T>

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

class RefreshingMemoizingSupplier<T> extends Object implements Memoize<T>
The object can exist in one of two states:
  • expired which means that System.nanoTime is greater than timebound. memoized may hold an expired value or null. The object transitions to this state when time_to_live elapses. This is the initial state. From this state, the object transitions to valued when @{code get} is called.
  • valued which means that System.nanoTime is less than timebound. memoized holds the current value.
  • Field Details

    • supplier

      private final Supplier<? extends T> supplier
    • time_to_live

      private final long time_to_live
    • timebound

      private volatile long timebound
    • memoized

      private T memoized
  • Constructor Details

    • RefreshingMemoizingSupplier

      RefreshingMemoizingSupplier(Supplier<? extends T> supplier, long time_to_live, TimeUnit unit)
  • Method Details

    • get

      public T get()
      Description copied from interface: Memoize
      Get the memoized value.
      Specified by:
      get in interface Memoize<T>
      Specified by:
      get in interface Supplier<T>
      Returns:
      The memoized value.
    • 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 memoized value if a value is memoized; otherwise null.
    • isPresent

      public boolean isPresent()
      Description copied from interface: Memoize
      If a value is memoized, return true. Otherwise return false.

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

      Specified by:
      isPresent in interface Memoize<T>
      Returns:
      true if a value is memoized; otherwise false.
    • toString

      public String toString()
      Overrides:
      toString in class Object