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 com.google.common.annotations.Beta;
13 import java.util.Collection;
14 import java.util.Optional;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.yangtools.yang.common.QName;
19 * Node which can contain action nodes.
22 public interface ActionNodeContainer {
24 * Return the set of actions.
26 * @return set of action nodes
28 @NonNull Collection<? extends @NonNull ActionDefinition> getActions();
31 * Find an action based on its QName. Default implementation searches the set returned by {@link #getActions()}.
33 * @param qname Action's QName
34 * @return Action definition, if found
35 * @throws NullPointerException if qname is null
37 default Optional<ActionDefinition> findAction(final QName qname) {
38 requireNonNull(qname);
39 for (ActionDefinition action : getActions()) {
40 if (qname.equals(action.getQName())) {
41 return Optional.of(action);
44 return Optional.empty();