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.controller.md.sal.binding.impl;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ClassToInstanceMap;
13 import com.google.common.collect.ImmutableSet;
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;
26 final class ControllerActionServiceAdapter implements ActionService {
27 private static final class Builder extends BindingDOMAdapterBuilder<ActionService> {
29 public Set<? extends Class<? extends DOMService>> getRequiredDelegates() {
30 return ImmutableSet.of(DOMActionService.class);
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);
41 static final Factory<ActionService> BUILDER_FACTORY = Builder::new;
42 private final ActionServiceAdapter delegate;
44 ControllerActionServiceAdapter(final BindingToNormalizedNodeCodec codec, final DOMActionService domService) {
45 this.delegate = ActionServiceAdapter.create(codec, domService);
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);