
com.github.chaosfirebolt.converter.api.cache.NoOpCache Maven / Gradle / Ivy
package com.github.chaosfirebolt.converter.api.cache;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* Does not cache anything, computes value every time.
*
* @param type of the key, by which the value is saved
* @param type of the cached value
* @deprecated Deprecated since version 3.3.0
*/
@Deprecated(since = "3.3.0", forRemoval = true)
public abstract class NoOpCache extends BaseCache {
/**
* @param computation function to compute the value, if a cache is not found
* @param exceptionSupplier supplier for an exception to be thrown, if a value can't be returned
*/
protected NoOpCache(Function computation, Supplier extends RuntimeException> exceptionSupplier) {
super(computation, exceptionSupplier);
}
@Override
protected Optional computeIfAbsent(K key, Function computation) {
return Optional.ofNullable(computation.apply(key));
}
@Override
public void clear() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy