Class SupplierUtil

java.lang.Object
io.micronaut.core.util.SupplierUtil

public class SupplierUtil extends Object
Helper methods for dealing with Supplier.
Since:
1.0
Author:
James Kleeh
  • Constructor Details

    • SupplierUtil

      public SupplierUtil()
  • Method Details

    • memoized

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

      public static <T> Supplier<T> memoizedNonEmpty(Supplier<T> valueSupplier)
      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:
      valueSupplier - The supplier providing the result
      Returns:
      A new supplier that will cache the result