Class CachingSupplier<V>
java.lang.Object
io.github.douira.glsl_transformer.core.CachingSupplier<V>
- All Implemented Interfaces:
Supplier<V>
Wraps a supplier and caches its result according to a given cache policy.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCachingSupplier(CachePolicy cachePolicy, Supplier<V> generator) Creates a new caching supplier with a given cache policy and supplier. -
Method Summary
Modifier and TypeMethodDescriptionget()voidinvalidate(CachePolicy fulfilledPolicy) Invalidates the cached value if the cache policy of this caching supplier requires it based on the strength of the given cache invalidation event.static <V> Supplier<V>of(CachePolicy cachePolicy, Supplier<V> generator) Returns any supplier that supplies the same values as a caching supplier with the given cache policy and value generating supplier.
-
Constructor Details
-
CachingSupplier
Creates a new caching supplier with a given cache policy and supplier.- Parameters:
cachePolicy- The cache policygenerator- The supplier
-
-
Method Details
-
get
-
invalidate
Invalidates the cached value if the cache policy of this caching supplier requires it based on the strength of the given cache invalidation event.- Parameters:
fulfilledPolicy- The strength of the cache invalidation event
-
of
Returns any supplier that supplies the same values as a caching supplier with the given cache policy and value generating supplier. This means that if theCachePolicy#ALWAYSis used, the returned supplier will be the same as the given supplier.- Type Parameters:
V- The value type- Parameters:
cachePolicy- The cache policy to use on the returned suppliergenerator- The supplier to use on the returned supplier- Returns:
- A supplier with the given cache policy
-