All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opendaylight.mdsal.binding.dom.adapter.AbstractBindingLoadingAdapter Maven / Gradle / Ivy

There is a newer version: 14.0.2
Show newest version
/*
 * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.mdsal.binding.dom.adapter;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.eclipse.jdt.annotation.NonNullByDefault;

@NonNullByDefault
abstract class AbstractBindingLoadingAdapter extends AbstractBindingAdapter {
    private final LoadingCache proxies = CacheBuilder.newBuilder().weakKeys().weakValues().build(
        new CacheLoader() {
            @Override
            public V load(final K key) {
                return loadAdapter(key);
            }
        });

    AbstractBindingLoadingAdapter(final AdapterContext adapterContext, final D delegate) {
        super(adapterContext, delegate);
    }

    final V getAdapter(final K key) {
        return proxies.getUnchecked(key);
    }

    abstract V loadAdapter(K key);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy