Improve {Action,Notification}NodeContainerCompat safety
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / stmt / OperationDeclaredStatement.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.model.api.stmt;
9
10 import static com.google.common.base.Verify.verifyNotNull;
11
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;
17
18 /**
19  * Common interface for action and rpc statements.
20  */
21 @Beta
22 public interface OperationDeclaredStatement extends DocumentedDeclaredStatement.WithStatus<QName>,
23         IfFeatureAwareDeclaredStatement<QName> {
24     default @NonNull QName getName() {
25         // FIXME: YANGTOOLS-908: verifyNotNull() should not be needed here
26         return verifyNotNull(argument());
27     }
28
29     default @NonNull Optional<InputStatement> getInput() {
30         return findFirstDeclaredSubstatement(InputStatement.class);
31     }
32
33     default @NonNull Optional<OutputStatement> getOutput() {
34         return findFirstDeclaredSubstatement(OutputStatement.class);
35     }
36
37     default @NonNull Collection<? extends TypedefStatement> getTypedefs() {
38         return declaredSubstatements(TypedefStatement.class);
39     }
40
41     default @NonNull Collection<? extends GroupingStatement> getGroupings() {
42         return declaredSubstatements(GroupingStatement.class);
43     }
44 }