Package io.micronaut.core.util
Class SupplierUtil
- java.lang.Object
-
- io.micronaut.core.util.SupplierUtil
-
public class SupplierUtil extends java.lang.Object
Helper methods for dealing withSupplier
.- 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.
-
-
-
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
-
-