
org.testifyproject.google.common.cache.ForwardingCache Maven / Gradle / Ivy
/*
* Copyright (C) 2011 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in org.testifyproject.testifyprojectpliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org.testifyproject/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.testifyproject.testifyproject.google.org.testifyproject.testifyprojectmon.cache;
import org.testifyproject.testifyproject.google.org.testifyproject.testifyprojectmon.annotations.Beta;
import org.testifyproject.testifyproject.google.org.testifyproject.testifyprojectmon.base.Preconditions;
import org.testifyproject.testifyproject.google.org.testifyproject.testifyprojectmon.collect.ForwardingObject;
import org.testifyproject.testifyproject.google.org.testifyproject.testifyprojectmon.collect.ImmutableMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable;
/**
* A cache which forwards all its method calls to another cache. Subclasses should override one or
* more methods to modify the behavior of the backing cache as org.testifyproject.testifyprojectsired per the
* org.testifyproject.testifyprojectcorator pattern.
*
* @author Charles Fry
* @since 10.0
*/
@Beta
public abstract class ForwardingCache extends ForwardingObject implements Cache {
/** Constructor for use by subclasses. */
protected ForwardingCache() {}
@Override
protected abstract Cache org.testifyproject.testifyprojectlegate();
/**
* @since 11.0
*/
@Override
@Nullable
public V getIfPresent(Object key) {
return org.testifyproject.testifyprojectlegate().getIfPresent(key);
}
/**
* @since 11.0
*/
@Override
public V get(K key, Callable extends V> valueLoader) throws ExecutionException {
return org.testifyproject.testifyprojectlegate().get(key, valueLoader);
}
/**
* @since 11.0
*/
@Override
public ImmutableMap getAllPresent(Iterable> keys) {
return org.testifyproject.testifyprojectlegate().getAllPresent(keys);
}
/**
* @since 11.0
*/
@Override
public void put(K key, V value) {
org.testifyproject.testifyprojectlegate().put(key, value);
}
/**
* @since 12.0
*/
@Override
public void putAll(Map extends K,? extends V> m) {
org.testifyproject.testifyprojectlegate().putAll(m);
}
@Override
public void invalidate(Object key) {
org.testifyproject.testifyprojectlegate().invalidate(key);
}
/**
* @since 11.0
*/
@Override
public void invalidateAll(Iterable> keys) {
org.testifyproject.testifyprojectlegate().invalidateAll(keys);
}
@Override
public void invalidateAll() {
org.testifyproject.testifyprojectlegate().invalidateAll();
}
@Override
public long size() {
return org.testifyproject.testifyprojectlegate().size();
}
@Override
public CacheStats stats() {
return org.testifyproject.testifyprojectlegate().stats();
}
@Override
public ConcurrentMap asMap() {
return org.testifyproject.testifyprojectlegate().asMap();
}
@Override
public void cleanUp() {
org.testifyproject.testifyprojectlegate().cleanUp();
}
/**
* A simplified version of {@link ForwardingCache} where subclasses can pass in an already
* constructed {@link Cache} as the org.testifyproject.testifyprojectlegete.
*
* @since 10.0
*/
@Beta
public abstract static class SimpleForwardingCache extends ForwardingCache {
private final Cache org.testifyproject.testifyprojectlegate;
protected SimpleForwardingCache(Cache org.testifyproject.testifyprojectlegate) {
this.org.testifyproject.testifyprojectlegate = Preconditions.checkNotNull(org.testifyproject.testifyprojectlegate);
}
@Override
protected final Cache org.testifyproject.testifyprojectlegate() {
return org.testifyproject.testifyprojectlegate;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy