c88fa3dba105db9dafb07898d8518e5ea0d505bc
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / md / sal / binding / impl / ControllerActionServiceAdapter.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.ActionService;
17 import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
18 import org.opendaylight.controller.md.sal.dom.api.DOMActionService;
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.ActionServiceAdapter;
22 import org.opendaylight.yangtools.yang.binding.Action;
23 import org.opendaylight.yangtools.yang.binding.DataObject;
24
25 @Deprecated
26 final class ControllerActionServiceAdapter implements ActionService {
27     private static final class Builder extends BindingDOMAdapterBuilder<ActionService> {
28         @Override
29         public Set<? extends Class<? extends DOMService>> getRequiredDelegates() {
30             return ImmutableSet.of(DOMActionService.class);
31         }
32
33         @Override
34         protected ActionService createInstance(final BindingToNormalizedNodeCodec codec,
35                 final ClassToInstanceMap<DOMService> delegates) {
36             final DOMActionService domAction = delegates.getInstance(DOMActionService.class);
37             return new ControllerActionServiceAdapter(requireNonNull(codec), domAction);
38         }
39     }
40
41     static final Factory<ActionService> BUILDER_FACTORY = Builder::new;
42     private final ActionServiceAdapter delegate;
43
44     ControllerActionServiceAdapter(final BindingToNormalizedNodeCodec codec, final DOMActionService domService) {
45         this.delegate = ActionServiceAdapter.create(codec, domService);
46     }
47
48     @Override
49     public <O extends @NonNull DataObject, T extends @NonNull Action<?, ?, ?>> T getActionHandle(
50             final Class<T> actionInterface, final Set<DataTreeIdentifier<O>> validNodes) {
51         return delegate.getActionHandle(actionInterface, validNodes);
52     }
53 }

©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.