package org.ehcache.impl.internal.store.basic;
import org.ehcache.Cache;
import org.ehcache.core.CacheConfigurationChangeListener;
import org.ehcache.spi.resilience.StoreAccessException;
import org.ehcache.core.spi.store.events.StoreEventFilter;
import org.ehcache.core.spi.store.events.StoreEventListener;
import org.ehcache.core.spi.store.events.StoreEventSource;
import org.ehcache.core.spi.store.tiering.AuthoritativeTier;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
public class NopStore<K, V> implements AuthoritativeTier<K, V> {
@Override
public List<CacheConfigurationChangeListener> getConfigurationChangeListeners() {
return Collections.emptyList();
}
@Override
public ValueHolder<V> getAndFault(K key) throws StoreAccessException {
return null;
}
@Override
public ValueHolder<V> computeIfAbsentAndFault(K key, Function<? super K, ? extends V> mappingFunction) {
return null;
}
@Override
public boolean flush(K key, ValueHolder<V> valueHolder) {
return false;
}
@Override
public void setInvalidationValve(InvalidationValve valve) {
}
@Override
public ValueHolder<V> get(K key) {
return null;
}
@Override
public boolean containsKey(K key) {
return false;
}
@Override
public PutStatus put(K key, V value) throws StoreAccessException {
return PutStatus.PUT;
}
@Override
public ValueHolder<V> putIfAbsent(K key, V value, Consumer<Boolean> put) throws StoreAccessException {
return null;
}
@Override
public boolean remove(K key) throws StoreAccessException {
return false;
}
@Override
public RemoveStatus remove(K key, V value) throws StoreAccessException {
return RemoveStatus.KEY_MISSING;
}
@Override
public ValueHolder<V> replace(K key, V value) throws StoreAccessException {
return null;
}
@Override
public ReplaceStatus replace(K key, V oldValue, V newValue) throws StoreAccessException {
return ReplaceStatus.MISS_NOT_PRESENT;
}
@Override
public void clear() {
}
@Override
public StoreEventSource<K, V> getStoreEventSource() {
return new StoreEventSource<K, V>() {
@Override
public void addEventListener(StoreEventListener<K, V> eventListener) {
}
@Override
public void removeEventListener(StoreEventListener<K, V> eventListener) {
}
@Override
public void addEventFilter(StoreEventFilter<K, V> eventFilter) {
}
@Override
public void setEventOrdering(boolean ordering) {
}
@Override
public boolean isEventOrdering() {
return false;
}
};
}
@Override
public Iterator<Cache.Entry<K, ValueHolder<V>>> iterator() {
return new Iterator<Cache.Entry<K, ValueHolder<V>>>() {
@Override
public boolean hasNext() {
return false;
}
@Override
public Cache.Entry<K, ValueHolder<V>> next() {
throw new NoSuchElementException();
}
};
}
@Override
public ValueHolder<V> getAndCompute(K key, BiFunction<? super K, ? super V, ? extends V> mappingFunction) {
return null;
}
@Override
public ValueHolder<V> computeAndGet(K key, BiFunction<? super K, ? super V, ? extends V> mappingFunction, Supplier<Boolean> replaceEqual, Supplier<Boolean> invokeWriter) {
return null;
}
@Override
public ValueHolder<V> computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
return null;
}
@Override
public Map<K, ValueHolder<V>> bulkCompute(Set<? extends K> keys, Function<Iterable<? extends Map.Entry<? extends K, ? extends V>>, Iterable<? extends Map.Entry<? extends K, ? extends V>>> remappingFunction) throws StoreAccessException {
return bulkCompute(keys, remappingFunction, null);
}
@Override
public Map<K, ValueHolder<V>> bulkCompute(Set<? extends K> keys, Function<Iterable<? extends Map.Entry<? extends K, ? extends V>>, Iterable<? extends Map.Entry<? extends K, ? extends V>>> remappingFunction, Supplier<Boolean> replaceEqual) {
Map<K, ValueHolder<V>> map = new HashMap<>(keys.size());
for(K key : keys) {
map.put(key, null);
}
return map;
}
@Override
public Map<K, ValueHolder<V>> bulkComputeIfAbsent(Set<? extends K> keys, Function<Iterable<? extends K>, Iterable<? extends Map.Entry<? extends K, ? extends V>>> mappingFunction) {
Map<K, ValueHolder<V>> map = new HashMap<>(keys.size());
for(K key : keys) {
map.put(key, null);
}
return map;
}
}