/* * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.mdsal.binding.api; import com.google.common.annotations.Beta; import com.google.common.util.concurrent.MoreExecutors; import java.util.EventListener; import java.util.concurrent.Executor; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.Identifiable; import org.opendaylight.yangtools.yang.binding.Identifier; import org.opendaylight.yangtools.yang.binding.InstanceNotification; import org.opendaylight.yangtools.yang.binding.KeyedListNotification; /** * A {@link BindingService} which allows clients to subscribe to (YANG 1.1) {@link InstanceNotification}s and * {@link KeyedListNotification}s. */ @Beta public interface InstanceNotificationService extends BindingService {
, T extends Listener
>
@NonNull Registration registerListener(InstanceNotificationSpec path,
T listener, Executor executor);
default , T extends Listener >
@NonNull Registration registerListener(final InstanceNotificationSpec path, final T listener) {
return registerListener(spec, path, listener, MoreExecutors.directExecutor());
}
, N extends KeyedListNotification ,
T extends KeyedListListener > @NonNull Registration registerListener(
InstanceNotificationSpec path, T listener, Executor executor);
default , N extends KeyedListNotification ,
T extends KeyedListListener > @NonNull Registration registerListener(
final InstanceNotificationSpec path, final T listener) {
return registerListener(spec, path, listener, MoreExecutors.directExecutor());
}
/*
* Interface for listeners on instance (YANG 1.1) notifications.
*/
@FunctionalInterface
interface Listener > extends EventListener {
/**
* Process an instance notification.
*
* @param path Instance path
* @param notification Notification body
*/
void onNotification(@NonNull DataTreeIdentifier path, @NonNull N notification);
}
/**
* Interface for listeners on instance (YANG 1.1) notifications defined in a {@code list} with a {@code key}.
*/
@FunctionalInterface
interface KeyedListListener , N extends KeyedListNotification > extends EventListener {
/**
* Process an instance notification.
*
* @param path Instance path
* @param notification Notification body
*/
// FIXME: DataTreeIdentifier does not have a Keyed flavor
void onNotification(@NonNull DataTreeIdentifier path, @NonNull N notification);
}
}