- java.lang.Object
-
- org.microbean.function.Suppliers
-
public final class Suppliers extends Object
A utility class containing useful operations forSupplier
s.- Author:
- Laird Nelson
-
-
Method Detail
-
memoize
public static final <R> Supplier<R> memoize(Supplier<? extends R> s)
Memoizes the suppliedSupplier
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
- theSupplier
to memoize; must not benull
- Returns:
- a memoized version of the supplied
Supplier
; nevernull
- Throws:
NullPointerException
- ifs
isnull
-
memoize
public static final <R> Supplier<R> memoize(Supplier<? extends R> s, Duration d)
Memoizes the suppliedSupplier
for a time equal to that represented by the suppliedDuration
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
- theSupplier
to memoize; must not benull
d
- theDuration
expressing 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 suppliedSupplier
for 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
- theSupplier
to memoize; must not benull
durationNanos
- 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
-
-