bf6b991ab98d8e9f450cfa2534534202f036d14f
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / md / sal / binding / impl / ControllerActionProviderServiceAdapter.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.binding.impl;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.collect.ClassToInstanceMap;
13 import com.google.common.collect.ImmutableSet;
14 import java.util.Set;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.controller.md.sal.binding.api.ActionProviderService;
17 import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
18 import org.opendaylight.controller.md.sal.dom.api.DOMActionProviderService;
19 import org.opendaylight.controller.md.sal.dom.api.DOMService;
20 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
21 import org.opendaylight.mdsal.binding.dom.adapter.ActionProviderServiceAdapter;
22 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
23 import org.opendaylight.yangtools.concepts.ObjectRegistration;
24 import org.opendaylight.yangtools.yang.binding.Action;
25 import org.opendaylight.yangtools.yang.binding.DataObject;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27
28 @Deprecated
29 final class ControllerActionProviderServiceAdapter implements ActionProviderService {
30     private static final class Builder extends BindingDOMAdapterBuilder<ActionProviderService> {
31         @Override
32         public Set<? extends Class<? extends DOMService>> getRequiredDelegates() {
33             return ImmutableSet.of(DOMActionProviderService.class);
34         }
35
36         @Override
37         protected ActionProviderService createInstance(BindingToNormalizedNodeCodec codec,
38                 ClassToInstanceMap<DOMService> delegates) {
39             final DOMActionProviderService domAction = delegates.getInstance(DOMActionProviderService.class);
40             return new ControllerActionProviderServiceAdapter(requireNonNull(codec), domAction);
41         }
42     }
43
44     static final Factory<ActionProviderService> BUILDER_FACTORY = Builder::new;
45
46     private final ActionProviderServiceAdapter delegate;
47
48     ControllerActionProviderServiceAdapter(BindingToNormalizedNodeCodec codec, DOMActionProviderService domService) {
49         this.delegate = ActionProviderServiceAdapter.create(codec, domService);
50     }
51
52     @Override
53     public <O extends @NonNull DataObject, P extends @NonNull InstanceIdentifier<O>, T extends @NonNull Action<P, ?, ?>,
54             S extends T> ObjectRegistration<S> registerImplementation(Class<T> actionInterface, S implementation,
55                     LogicalDatastoreType datastore, Set<DataTreeIdentifier<O>> validNodes) {
56         return delegate.registerImplementation(actionInterface, implementation, datastore, validNodes);
57     }
58 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.