Package org.anchoranalysis.core.cache
Class CachedSupplierBase<T>
Object
CachedSupplierBase<T>
- Type Parameters:
T
- result-type
- Direct Known Subclasses:
CachedSupplier
Base class for functions that memoize (cache) a call to an interface.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall
(CheckedSupplier<T, E> supplier) Gets the value supplied bysupplier
via the cache if it exists, or otherwise via the supplier.boolean
Has the function already been evaluated?void
reset()
Ensures the object is unevaluated, deleting any cached result if it exists.
-
Constructor Details
-
CachedSupplierBase
public CachedSupplierBase()
-
-
Method Details
-
isEvaluated
public boolean isEvaluated()Has the function already been evaluated?i.e. does a value already exist in the cache.
- Returns:
- true iff a value exists in the cache.
-
call
Gets the value supplied bysupplier
via the cache if it exists, or otherwise via the supplier.The value is then cached, and the object is considered as evaluated.
- Type Parameters:
E
- an exception that can be thrown bysupplier
.- Parameters:
supplier
- the operation used to create the value.- Returns:
- the value, either created or from the cache.
- Throws:
E
- if thrown bysupplier
.
-
reset
public void reset()Ensures the object is unevaluated, deleting any cached result if it exists.
-