All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opendaylight.yangtools.yang.model.api.NotificationNodeContainer Maven / Gradle / Ivy

There is a newer version: 14.0.4
Show newest version
/*
 * Copyright (c) 2016 Cisco Systems, Inc. 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.yangtools.yang.model.api;

import static java.util.Objects.requireNonNull;

import java.util.Collection;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QName;

public interface NotificationNodeContainer {
    /**
     * Return the set of notifications in this container, keyed by QName. RFC7950 specifies that
     * {@link AugmentationSchemaNode}s, {@link GroupingDefinition}s, {@link ListSchemaNode}s and
     * {@link ContainerSchemaNode}s can also contain {@link NotificationDefinition}s.
      *
     * @return set of notification nodes
     */
    @NonNull Collection getNotifications();

    /**
     * Find a notification based on its QName. Default implementation searches the set returned by
     * {@link #getNotifications()}.
     *
     * @param qname Notification QName
     * @return Notification definition, if found
     * @throws NullPointerException if qname is null
     */
    default Optional findNotification(final QName qname) {
        requireNonNull(qname);
        for (NotificationDefinition notif : getNotifications()) {
            if (qname.equals(notif.getQName())) {
                return Optional.of(notif);
            }
        }
        return Optional.empty();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy