Class CacheSupplier<T>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    Supplier<T>

    public class CacheSupplier<T>
    extends Object
    implements Supplier<T>
    Delegates the first get() call to the given supplier and stores its result in cache. Consecutive calls return the cached result, therefore computation is only done once. Does not maintain a reference to the delegate once its result is computed.
    Author:
    Mathias Hofer
    • Constructor Detail

      • CacheSupplier

        public CacheSupplier​(Supplier<T> delegate)
    • Method Detail

      • get

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