2 * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.md.sal.binding.spi;
10 import com.google.common.base.Optional;
11 import com.google.common.cache.CacheLoader;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.gaul.modernizer_maven_annotations.SuppressModernizer;
16 @Deprecated(forRemoval = true)
17 public abstract class AdapterLoader<T, D> extends CacheLoader<Class<? extends T>, Optional<T>> {
21 public Optional<T> load(final Class<? extends T> key) {
23 final AdapterBuilder<? extends T, D> builder = createBuilder(key);
24 for (final Class<? extends D> reqDeleg : builder.getRequiredDelegates()) {
25 final D deleg = getDelegate(reqDeleg);
27 builder.addDelegate(reqDeleg, deleg);
29 return Optional.absent();
32 return Optional.<T>of(builder.build());
35 protected abstract @Nullable D getDelegate(Class<? extends D> reqDeleg);
37 protected abstract @NonNull AdapterBuilder<? extends T, D> createBuilder(Class<? extends T> key);