- java.lang.Object
-
- org.microbean.function.Suppliers
-
public final class Suppliers extends Object
A utility class containing useful operations forSuppliers.- Author:
- Laird Nelson
-
-
Method Detail
-
memoize
public static final <R> Supplier<R> memoize(Supplier<? extends R> s)
Memoizes the suppliedSupplierand returns the memoization.The memoization will not call the supplied
Supplier'sget()method until its ownget()method is called.- Type Parameters:
R- the return type of the suppliedSupplier- Parameters:
s- theSupplierto memoize; must not benull- Returns:
- a memoized version of the supplied
Supplier; nevernull - Throws:
NullPointerException- ifsisnull
-
memoize
public static final <R> Supplier<R> memoize(Supplier<? extends R> s, Duration d)
Memoizes the suppliedSupplierfor a time equal to that represented by the suppliedDurationand returns the memoization.The memoization will not call the supplied
Supplier'sget()method until its ownget()method is called.- Type Parameters:
R- the return type of the suppliedSupplier- Parameters:
s- theSupplierto memoize; must not benulld- theDurationexpressing how long the memoization will survive; must not benull- Returns:
- a memoized version of the supplied
Supplier; nevernull - Throws:
NullPointerException- if either argument isnull- See Also:
memoize(Supplier, long)
-
memoize
public static final <R> Supplier<R> memoize(Supplier<? extends R> s, long durationNanos)
Memoizes the suppliedSupplierfor a time equal to that represented by the supplied number of nanoseconds and returns the memoization.The memoization will not call the supplied
Supplier'sget()method until its ownget()method is called.- Type Parameters:
R- the return type of the suppliedSupplier- Parameters:
s- theSupplierto memoize; must not benulldurationNanos- the duration, in nanoseconds, expressing how long the memoization will survive- Returns:
- a memoized version of the supplied
Supplier; nevernull - Throws:
NullPointerException- if either argument isnull
-
-