2 * Copyright (c) 2016 Cisco Systems, Inc. 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.yangtools.yang.model.api;
10 import static java.util.Objects.requireNonNull;
12 import java.util.Collection;
13 import java.util.Optional;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.yangtools.yang.common.QName;
18 * Node which can contain {@link ActionDefinition}.
20 public interface ActionNodeContainer {
22 * Return the set of actions.
24 * @return set of action nodes
26 @NonNull Collection<? extends @NonNull ActionDefinition> getActions();
29 * Find an action based on its QName. Default implementation searches the set returned by {@link #getActions()}.
31 * @param qname Action's QName
32 * @return Action definition, if found
33 * @throws NullPointerException if {@code qname} is {@code null}
35 default Optional<ActionDefinition> findAction(final QName qname) {
36 requireNonNull(qname);
37 for (var action : getActions()) {
38 if (qname.equals(action.getQName())) {
39 return Optional.of(action);
42 return Optional.empty();