Package org.anchoranalysis.core.cache
Class CachedSupplier<T,E extends Exception>
Object
CachedSupplierBase<T>
CachedSupplier<T,E>
- Type Parameters:
T
- result-typeE
- exception that is thrown if something goes wrong
- All Implemented Interfaces:
CheckedSupplier<T,
E>
public class CachedSupplier<T,E extends Exception>
extends CachedSupplierBase<T>
implements CheckedSupplier<T,E>
Memoizes (caches) a
CheckedSupplier
.- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
E extends Exception>
CachedSupplier<T, E> Creates a cached-version of aSupplier
.static <T,
E extends Exception>
CachedSupplier<T, E> cacheChecked
(CheckedSupplier<T, E> suppplier) Creates a cached-version of aCheckedSupplier
.get()
Applies a supplier like withSupplier.get()
.Methods inherited from class org.anchoranalysis.core.cache.CachedSupplierBase
call, isEvaluated, reset
-
Method Details
-
cache
Creates a cached-version of aSupplier
.- Type Parameters:
T
- return-typeE
- exception that will never be thrown, but is parameterized to match the destination-type..- Parameters:
suppplier
- supplies the value to be calculated and cached.- Returns:
- a cached version, with the same interface, and additional functions to monitor progress, reset etc.
-
cacheChecked
public static <T,E extends Exception> CachedSupplier<T,E> cacheChecked(CheckedSupplier<T, E> suppplier) Creates a cached-version of aCheckedSupplier
.- Type Parameters:
T
- return-typeE
- exception that may be thrown.- Parameters:
suppplier
- supplies the value to be calculated and cached.- Returns:
- a cached version, with the same interface, and additional functions to monitor progress, reset etc.
-
get
Description copied from interface:CheckedSupplier
Applies a supplier like withSupplier.get()
.- Specified by:
get
in interfaceCheckedSupplier<T,
E extends Exception> - Returns:
- the supplied object.
- Throws:
E
-