2 * Copyright (c) 2022 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.api;
10 import com.google.common.annotations.Beta;
11 import com.google.common.util.concurrent.MoreExecutors;
12 import java.util.concurrent.Executor;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.concepts.Registration;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.opendaylight.yangtools.yang.binding.InstanceNotification;
18 import org.opendaylight.yangtools.yang.binding.Key;
19 import org.opendaylight.yangtools.yang.binding.KeyAware;
20 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
21 import org.opendaylight.yangtools.yang.binding.KeyedListNotification;
24 * A {@link BindingService} which allows clients to subscribe to (YANG 1.1) {@link InstanceNotification}s and
25 * {@link KeyedListNotification}s.
28 public interface InstanceNotificationService extends BindingService {
30 <P extends DataObject, N extends InstanceNotification<N, P>> @NonNull Registration registerListener(
31 InstanceNotificationSpec<N, P> spec, InstanceIdentifier<P> path, Listener<P, N> listener, Executor executor);
33 default <P extends DataObject, N extends InstanceNotification<N, P>> @NonNull Registration registerListener(
34 final InstanceNotificationSpec<N, P> spec, final InstanceIdentifier<P> path,
35 final Listener<P, N> listener) {
36 return registerListener(spec, path, listener, MoreExecutors.directExecutor());
39 <P extends DataObject & KeyAware<K>, N extends KeyedListNotification<N, P, K>, K extends Key<P>>
40 @NonNull Registration registerListener(InstanceNotificationSpec<N, P> spec, KeyedInstanceIdentifier<P, K> path,
41 KeyedListListener<P, N, K> listener, Executor executor);
43 default <P extends DataObject & KeyAware<K>, N extends KeyedListNotification<N, P, K>, K extends Key<P>>
44 @NonNull Registration registerListener(final InstanceNotificationSpec<N, P> spec,
45 final KeyedInstanceIdentifier<P, K> path, final KeyedListListener<P, N, K> listener) {
46 return registerListener(spec, path, listener, MoreExecutors.directExecutor());
50 * Interface for listeners on instance (YANG 1.1) notifications.
53 interface Listener<P extends DataObject, N extends InstanceNotification<N, P>> {
55 * Process an instance notification.
57 * @param path Instance path
58 * @param notification Notification body
60 void onNotification(@NonNull InstanceIdentifier<P> path, @NonNull N notification);
64 * Interface for listeners on instance (YANG 1.1) notifications defined in a {@code list} with a {@code key}.
67 interface KeyedListListener<P extends DataObject & KeyAware<K>, N extends KeyedListNotification<N, P, K>,
70 * Process an instance notification.
72 * @param path Instance path
73 * @param notification Notification body
75 void onNotification(@NonNull KeyedInstanceIdentifier<P, K> path, @NonNull N notification);