Class CachedSupplier<T,E extends Exception>

Object
CachedSupplierBase<T>
CachedSupplier<T,E>
Type Parameters:
T - result-type
E - exception that is thrown if something goes wrong
All Implemented Interfaces:
CheckedSupplier<T,E>

public class CachedSupplier<T,E extends Exception> extends CachedSupplierBase<T> implements CheckedSupplier<T,E>
Memoizes (caches) a CheckedSupplier.
Author:
Owen Feehan
  • Method Details

    • cache

      public static <T, E extends Exception> CachedSupplier<T,E> cache(Supplier<T> suppplier)
      Creates a cached-version of a Supplier.
      Type Parameters:
      T - return-type
      E - exception that will never be thrown, but is parameterized to match the destination-type..
      Parameters:
      suppplier - supplies the value to be calculated and cached.
      Returns:
      a cached version, with the same interface, and additional functions to monitor progress, reset etc.
    • cacheChecked

      public static <T, E extends Exception> CachedSupplier<T,E> cacheChecked(CheckedSupplier<T,E> suppplier)
      Creates a cached-version of a CheckedSupplier.
      Type Parameters:
      T - return-type
      E - exception that may be thrown.
      Parameters:
      suppplier - supplies the value to be calculated and cached.
      Returns:
      a cached version, with the same interface, and additional functions to monitor progress, reset etc.
    • get

      public T get() throws E
      Description copied from interface: CheckedSupplier
      Applies a supplier like with Supplier.get().
      Specified by:
      get in interface CheckedSupplier<T,E extends Exception>
      Returns:
      the supplied object.
      Throws:
      E