/* * 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.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.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.InstanceNotification; import org.opendaylight.yangtools.yang.binding.Key; import org.opendaylight.yangtools.yang.binding.KeyAware; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; 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 {
> @NonNull Registration registerListener(
InstanceNotificationSpec path, Listener listener, Executor executor);
default > @NonNull Registration registerListener(
final InstanceNotificationSpec path,
final Listener listener) {
return registerListener(spec, path, listener, MoreExecutors.directExecutor());
}
, N extends KeyedListNotification >
@NonNull Registration registerListener(InstanceNotificationSpec path,
KeyedListListener listener, Executor executor);
default , N extends KeyedListNotification >
@NonNull Registration registerListener(final InstanceNotificationSpec path, final KeyedListListener listener) {
return registerListener(spec, path, listener, MoreExecutors.directExecutor());
}
/*
* Interface for listeners on instance (YANG 1.1) notifications.
*/
@FunctionalInterface
interface Listener > {
/**
* Process an instance notification.
*
* @param path Instance path
* @param notification Notification body
*/
void onNotification(@NonNull InstanceIdentifier 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 > {
/**
* Process an instance notification.
*
* @param path Instance path
* @param notification Notification body
*/
void onNotification(@NonNull KeyedInstanceIdentifier path, @NonNull N notification);
}
}