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.Notification;
17 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
19 final class SingleBindingDOMNotificationAdapter<N extends Notification> extends AbstractDOMNotificationListenerAdapter {
20 private final Listener<N> delegate;
21 private final Executor executor;
22 private final Class<N> type;
24 SingleBindingDOMNotificationAdapter(final AdapterContext adapterContext, final Class<N> type,
25 final Listener<N> delegate, final Executor executor) {
26 super(adapterContext);
27 this.type = requireNonNull(type);
28 this.delegate = requireNonNull(delegate);
29 this.executor = requireNonNull(executor);
33 void onNotification(final Absolute domType, final Notification notification) {
34 executor.execute(() -> delegate.onNotification(type.cast(notification)));
38 Set<Absolute> getSupportedNotifications() {
39 return Set.of(Absolute.of(BindingReflections.findQName(type)));