2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.dom.adapter;
10 import com.google.common.cache.CacheBuilder;
11 import com.google.common.cache.CacheLoader;
12 import com.google.common.cache.LoadingCache;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
16 abstract class AbstractBindingLoadingAdapter<D, K, V> extends AbstractBindingAdapter<D> {
17 private final LoadingCache<K, V> proxies = CacheBuilder.newBuilder().weakKeys().build(new CacheLoader<K, V>() {
19 public V load(final K key) {
20 return loadAdapter(key);
24 AbstractBindingLoadingAdapter(final BindingToNormalizedNodeCodec codec, final D delegate) {
25 super(codec, delegate);
28 final V getAdapter(final K key) {
29 return proxies.getUnchecked(key);
32 abstract V loadAdapter(K key);