Class CachingSupplier<T>

  • Type Parameters:
    T - the type of results supplied by this supplier
    All Implemented Interfaces:
    java.util.function.Supplier<T>

    public class CachingSupplier<T>
    extends java.lang.Object
    implements java.util.function.Supplier<T>
    Supplier that caches the value.

    This is not threadsafe.

    • Field Summary

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

      Constructors 
      Constructor Description
      CachingSupplier​(java.util.function.Supplier<T> supplier)  
    • 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 final java.util.function.Supplier<T> delegate
      • cached

        private T cached
    • Constructor Detail

      • CachingSupplier

        public CachingSupplier​(java.util.function.Supplier<T> supplier)
    • Method Detail

      • get

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