Class CachedSupplier<T>

  • Type Parameters:
    T - the type cached
    All Implemented Interfaces:
    java.util.function.Supplier<T>

    public class CachedSupplier<T>
    extends java.lang.Object
    implements java.util.function.Supplier<T>
    Supplier that caches the output.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private T cache  
      private java.util.function.Supplier<T> delegate  
    • Constructor Summary

      Constructors 
      Constructor Description
      CachedSupplier​(java.util.function.Supplier<T> delegate)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T get()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • delegate

        private volatile java.util.function.Supplier<T> delegate
      • cache

        private volatile T cache
    • Constructor Detail

      • CachedSupplier

        public CachedSupplier​(java.util.function.Supplier<T> delegate)
    • Method Detail

      • get

        public T get()
        Specified by:
        get in interface java.util.function.Supplier<T>