Class DefaultMemoizingSupplier<T>
java.lang.Object
io.fluxzero.common.DefaultMemoizingSupplier<T>
- Type Parameters:
T- the type of the value supplied and memoized
- All Implemented Interfaces:
MemoizingSupplier<T>, Supplier<T>
A default implementation of the
MemoizingSupplier interface that memoizes (caches)
the result of a computation performed by a supplied Supplier.
The result is computed the first time get() is called and then cached for subsequent calls
until explicitly cleared with clear(). This implementation also supports an optional expiration
duration for the cached value.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultMemoizingSupplier(Supplier<T> delegate) DefaultMemoizingSupplier(Supplier<T> delegate, Duration lifespan, Clock clock) -
Method Summary
-
Constructor Details
-
DefaultMemoizingSupplier
-
DefaultMemoizingSupplier
-
-
Method Details
-
get
-
isCached
public boolean isCached()Description copied from interface:MemoizingSupplierReturns whether this supplier has already cached a value.- Specified by:
isCachedin interfaceMemoizingSupplier<T>
-
clear
public void clear()Description copied from interface:MemoizingSupplierClears the cached value, forcing the next call to recompute.- Specified by:
clearin interfaceMemoizingSupplier<T>
-