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.EventListener;
13 import java.util.concurrent.Executor;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.yangtools.concepts.Registration;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.Identifiable;
18 import org.opendaylight.yangtools.yang.binding.Identifier;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.opendaylight.yangtools.yang.binding.InstanceNotification;
21 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
22 import org.opendaylight.yangtools.yang.binding.KeyedListNotification;
25 * A {@link BindingService} which allows clients to subscribe to (YANG 1.1) {@link InstanceNotification}s and
26 * {@link KeyedListNotification}s.
29 public interface InstanceNotificationService extends BindingService {
31 <P extends DataObject, N extends InstanceNotification<N, P>> @NonNull Registration registerListener(
32 InstanceNotificationSpec<N, P> spec, InstanceIdentifier<P> path, Listener<P, N> listener, Executor executor);
34 default <P extends DataObject, N extends InstanceNotification<N, P>> @NonNull Registration registerListener(
35 final InstanceNotificationSpec<N, P> spec, final InstanceIdentifier<P> path,
36 final Listener<P, N> listener) {
37 return registerListener(spec, path, listener, MoreExecutors.directExecutor());
40 <P extends DataObject & Identifiable<K>, N extends KeyedListNotification<N, P, K>, K extends Identifier<P>>
41 @NonNull Registration registerListener(InstanceNotificationSpec<N, P> spec, KeyedInstanceIdentifier<P, K> path,
42 KeyedListListener<P, N, K> listener, Executor executor);
44 default <P extends DataObject & Identifiable<K>, N extends KeyedListNotification<N, P, K>, K extends Identifier<P>>
45 @NonNull Registration registerListener(final InstanceNotificationSpec<N, P> spec,
46 final KeyedInstanceIdentifier<P, K> path, final KeyedListListener<P, N, K> listener) {
47 return registerListener(spec, path, listener, MoreExecutors.directExecutor());
51 * Interface for listeners on instance (YANG 1.1) notifications.
54 interface Listener<P extends DataObject, N extends InstanceNotification<N, P>> extends EventListener {
56 * Process an instance notification.
58 * @param path Instance path
59 * @param notification Notification body
61 void onNotification(@NonNull InstanceIdentifier<P> path, @NonNull N notification);
65 * Interface for listeners on instance (YANG 1.1) notifications defined in a {@code list} with a {@code key}.
68 interface KeyedListListener<P extends DataObject & Identifiable<K>, N extends KeyedListNotification<N, P, K>,
69 K extends Identifier<P>> extends EventListener {
71 * Process an instance notification.
73 * @param path Instance path
74 * @param notification Notification body
76 void onNotification(@NonNull KeyedInstanceIdentifier<P, K> path, @NonNull N notification);