Class Suppliers


  • public class Suppliers
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Suppliers()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.function.Supplier<T> memoize​(java.util.function.Supplier<T> delegate)
      Returns a supplier which caches the instance retrieved during the first call to get() and returns that value on subsequent calls to get().
      • Methods inherited from class java.lang.Object

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

      • Suppliers

        public Suppliers()
    • Method Detail

      • memoize

        public static <T> java.util.function.Supplier<T> memoize​(java.util.function.Supplier<T> delegate)
        Returns a supplier which caches the instance retrieved during the first call to get() and returns that value on subsequent calls to get(). See: memoization

        The returned supplier is thread-safe. The delegate's get() method will be invoked at most once. The supplier's serialized form does not contain the cached value, which will be recalculated when get() is called on the reserialized instance.

        If delegate is an instance created by an earlier call to memoize, it is returned directly.