Class SupplierUtil


  • public class SupplierUtil
    extends java.lang.Object
    Helper methods for dealing with Supplier.
    Since:
    1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      SupplierUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.function.Supplier<T> memoized​(java.util.function.Supplier<T> actual)
      Caches the result of supplier in a thread safe manner.
      static <T> java.util.function.Supplier<T> memoizedNonEmpty​(java.util.function.Supplier<T> actual)
      Caches the result of supplier in a thread safe manner.
      • Methods inherited from class java.lang.Object

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

      • SupplierUtil

        public SupplierUtil()
    • Method Detail

      • memoized

        public static <T> java.util.function.Supplier<T> memoized​(java.util.function.Supplier<T> actual)
        Caches the result of supplier in a thread safe manner.
        Type Parameters:
        T - The type of result
        Parameters:
        actual - The supplier providing the result
        Returns:
        A new supplier that will cache the result
      • memoizedNonEmpty

        public static <T> java.util.function.Supplier<T> memoizedNonEmpty​(java.util.function.Supplier<T> actual)
        Caches the result of supplier in a thread safe manner. The result is only cached if it is non null or non empty if an optional.
        Type Parameters:
        T - The type of result
        Parameters:
        actual - The supplier providing the result
        Returns:
        A new supplier that will cache the result