Package com.dua3.utility.lang
Class LangUtil.AutoClosableCachingSupplier<T extends @Nullable Object>
java.lang.Object
com.dua3.utility.lang.LangUtil.StrongCachingSupplier<T>
com.dua3.utility.lang.LangUtil.AutoClosableCachingSupplier<T>
- Type Parameters:
T- the type of the object supplied, which may be nullable
- All Implemented Interfaces:
LangUtil.AutoCloseableSupplier<T>,LangUtil.CachingSupplier<T>,AutoCloseable,Supplier<T>
- Enclosing class:
LangUtil
public static final class LangUtil.AutoClosableCachingSupplier<T extends @Nullable Object>
extends LangUtil.StrongCachingSupplier<T>
implements LangUtil.AutoCloseableSupplier<T>
A supplier implementation that extends
CachingSupplier and implements the AutoCloseableSupplier
interface. This class provides the capability to cache the result of a computation and automatically clean up
resources when the cache is reset or the instance is closed.
When the cached value is invalidated, either through reset() or close(), a provided Consumer
is invoked to clean up any associated resources.
-
Field Summary
Fields inherited from class com.dua3.utility.lang.LangUtil.StrongCachingSupplier
initialized, obj, supplier -
Method Summary
Methods inherited from class com.dua3.utility.lang.LangUtil.StrongCachingSupplier
isInitialized
-
Method Details
-
get
-
reset
public void reset()Description copied from class:LangUtil.StrongCachingSupplierResets the internal state of this supplier by clearing the cached object and marking it as uninitialized. After calling this method, the next invocation ofLangUtil.StrongCachingSupplier.get()will recompute and cache the value by invoking the underlying supplier.The method has no effect if the supplier is already in the uninitialized state.
- Specified by:
resetin interfaceLangUtil.CachingSupplier<T extends @Nullable Object>- Overrides:
resetin classLangUtil.StrongCachingSupplier<T extends @Nullable Object>
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceLangUtil.AutoCloseableSupplier<T extends @Nullable Object>
-