Class MemoizingSupplier<T>

java.lang.Object
org.jdbi.v3.core.internal.MemoizingSupplier<T>
Type Parameters:
T - The type of the object returned by this supplier.
All Implemented Interfaces:
Supplier<T>

public class MemoizingSupplier<T> extends Object implements Supplier<T>
Wraps a supplier and memoizes the object returned.
See Also:
  • Field Details

    • create

      private final Supplier<T> create
    • delegate

      private Supplier<T> delegate
    • initialized

      private volatile boolean initialized
    • value

      private T value
  • Constructor Details

    • MemoizingSupplier

      private MemoizingSupplier(Supplier<T> create)
  • Method Details

    • of

      public static <T> MemoizingSupplier<T> of(Supplier<T> supplier)
    • get

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

      private T internalGet()
    • ifInitialized

      public void ifInitialized(Consumer<T> consumer)
      Execute a method on the object returned from the supplier if the object was already created. Skips execution if the underlying object was never created.
      Parameters:
      consumer - A consumer for the object returned by this supplier.
    • init

      private T init()