diff options
Diffstat (limited to 'gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheBindingProxy.java')
-rw-r--r-- | gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheBindingProxy.java | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheBindingProxy.java b/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheBindingProxy.java deleted file mode 100644 index 0d1cf20bf3..0000000000 --- a/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheBindingProxy.java +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (C) 2018 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/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.google.gerrit.server.cache.h2; - -import com.google.common.cache.CacheLoader; -import com.google.common.cache.Weigher; -import com.google.gerrit.server.cache.CacheBinding; -import com.google.gerrit.server.cache.h2.H2CacheImpl.ValueHolder; -import com.google.inject.TypeLiteral; -import java.util.concurrent.TimeUnit; - -class H2CacheBindingProxy<K, V> implements CacheBinding<K, V> { - private static final String MSG_NOT_SUPPORTED = - "This is read-only wrapper. Modifications are not supported"; - - private final CacheBinding<K, V> source; - - H2CacheBindingProxy(CacheBinding<K, V> source) { - this.source = source; - } - - @Override - public Long expireAfterWrite(TimeUnit unit) { - return source.expireAfterWrite(unit); - } - - @SuppressWarnings("unchecked") - @Override - public Weigher<K, V> weigher() { - Weigher<K, V> weigher = source.weigher(); - if (weigher == null) { - return null; - } - - // introduce weigher that performs calculations - // on value that is being stored not on ValueHolder - return (Weigher<K, V>) - new Weigher<K, ValueHolder<V>>() { - @Override - public int weigh(K key, ValueHolder<V> value) { - return weigher.weigh(key, value.value); - } - }; - } - - @Override - public String name() { - return source.name(); - } - - @Override - public TypeLiteral<K> keyType() { - return source.keyType(); - } - - @Override - public TypeLiteral<V> valueType() { - return source.valueType(); - } - - @Override - public long maximumWeight() { - return source.maximumWeight(); - } - - @Override - public long diskLimit() { - return source.diskLimit(); - } - - @Override - public CacheLoader<K, V> loader() { - return source.loader(); - } - - @Override - public CacheBinding<K, V> maximumWeight(long weight) { - throw new RuntimeException(MSG_NOT_SUPPORTED); - } - - @Override - public CacheBinding<K, V> diskLimit(long limit) { - throw new RuntimeException(MSG_NOT_SUPPORTED); - } - - @Override - public CacheBinding<K, V> expireAfterWrite(long duration, TimeUnit durationUnits) { - throw new RuntimeException(MSG_NOT_SUPPORTED); - } - - @Override - public CacheBinding<K, V> loader(Class<? extends CacheLoader<K, V>> clazz) { - throw new RuntimeException(MSG_NOT_SUPPORTED); - } - - @Override - public CacheBinding<K, V> weigher(Class<? extends Weigher<K, V>> clazz) { - throw new RuntimeException(MSG_NOT_SUPPORTED); - } -} |