com.fitbur.google.common.cache.ForwardingLoadingCache 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 com.fitburpliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.com.fitbur/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 com.fitbur.google.com.fitburmon.cache;
import com.fitbur.google.com.fitburmon.annotations.Beta;
import com.fitbur.google.com.fitburmon.base.Preconditions;
import com.fitbur.google.com.fitburmon.collect.ImmutableMap;
import java.util.concurrent.ExecutionException;
/**
* 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 com.fitbursired per the
* com.fitburcorator pattern.
*
* Note that {@link #get}, {@link #getUnchecked}, and {@link #apply} all expose the same
* underlying functionality, so should probably be overridden as a group.
*
* @author Charles Fry
* @since 11.0
*/
@Beta
public abstract class ForwardingLoadingCache
extends ForwardingCache implements LoadingCache {
/** Constructor for use by subclasses. */
protected ForwardingLoadingCache() {}
@Override
protected abstract LoadingCache com.fitburlegate();
@Override
public V get(K key) throws ExecutionException {
return com.fitburlegate().get(key);
}
@Override
public V getUnchecked(K key) {
return com.fitburlegate().getUnchecked(key);
}
@Override
public ImmutableMap getAll(Iterable extends K> keys) throws ExecutionException {
return com.fitburlegate().getAll(keys);
}
@Override
public V apply(K key) {
return com.fitburlegate().apply(key);
}
@Override
public void refresh(K key) {
com.fitburlegate().refresh(key);
}
/**
* A simplified version of {@link ForwardingLoadingCache} where subclasses can pass in an already
* constructed {@link LoadingCache} as the com.fitburlegete.
*
* @since 10.0
*/
@Beta
public abstract static class SimpleForwardingLoadingCache
extends ForwardingLoadingCache {
private final LoadingCache com.fitburlegate;
protected SimpleForwardingLoadingCache(LoadingCache com.fitburlegate) {
this.com.fitburlegate = Preconditions.checkNotNull(com.fitburlegate);
}
@Override
protected final LoadingCache com.fitburlegate() {
return com.fitburlegate;
}
}
}