/* * 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 spec, InstanceIdentifier

path, Listener listener, Executor executor); default

> @NonNull Registration registerListener( final InstanceNotificationSpec spec, final InstanceIdentifier

path, final Listener listener) { return registerListener(spec, path, listener, MoreExecutors.directExecutor()); }

, N extends KeyedListNotification, K extends Key

> @NonNull Registration registerListener(InstanceNotificationSpec spec, KeyedInstanceIdentifier path, KeyedListListener listener, Executor executor); default

, N extends KeyedListNotification, K extends Key

> @NonNull Registration registerListener(final InstanceNotificationSpec spec, final KeyedInstanceIdentifier 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, K extends Key

> { /** * Process an instance notification. * * @param path Instance path * @param notification Notification body */ void onNotification(@NonNull KeyedInstanceIdentifier path, @NonNull N notification); } }