2 * Copyright (c) 2021 PANTHEON.tech, 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.mdsal.binding.dom.adapter;
10 import static java.util.Objects.requireNonNull;
13 import java.util.concurrent.Executor;
14 import org.opendaylight.mdsal.binding.api.NotificationService.Listener;
15 import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.Notification;
18 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
20 final class SingleBindingDOMNotificationAdapter<N extends Notification<N> & DataObject>
21 extends AbstractDOMNotificationListenerAdapter {
22 private final Listener<N> delegate;
23 private final Executor executor;
24 private final Class<N> type;
26 SingleBindingDOMNotificationAdapter(final AdapterContext adapterContext, final Class<N> type,
27 final Listener<N> delegate, final Executor executor) {
28 super(adapterContext);
29 this.type = requireNonNull(type);
30 this.delegate = requireNonNull(delegate);
31 this.executor = requireNonNull(executor);
35 void onNotification(final Absolute domType, final Notification notification) {
36 executor.execute(() -> delegate.onNotification(type.cast(notification)));
40 Set<Absolute> getSupportedNotifications() {
41 return Set.of(Absolute.of(BindingReflections.findQName(type)));