2 * Copyright (c) 2017 Pantheon Technologies, s.r.o. 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.parser.rfc7950.stmt.input;
10 import com.google.common.collect.ImmutableList;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.common.YangConstants;
13 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
14 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
15 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
17 import org.opendaylight.yangtools.yang.model.api.stmt.InputEffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.InputStatement;
19 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseOperationContainerStatementSupport;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
22 abstract class AbstractInputStatementSupport
23 extends BaseOperationContainerStatementSupport<InputStatement, InputEffectiveStatement> {
24 AbstractInputStatementSupport() {
25 super(YangStmtMapping.INPUT, YangConstants::operationInputQName);
29 protected final InputStatement createDeclared(final StmtContext<QName, InputStatement, ?> ctx,
30 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
31 final StatementSource source = ctx.getStatementSource();
32 switch (ctx.getStatementSource()) {
34 return new RegularUndeclaredInputStatement(ctx.coerceStatementArgument(), substatements);
36 return new RegularInputStatement(ctx.coerceStatementArgument(), substatements);
38 throw new IllegalStateException("Unhandled statement source " + source);
43 protected final InputStatement createEmptyDeclared(final StmtContext<QName, InputStatement, ?> ctx) {
44 final StatementSource source = ctx.getStatementSource();
45 switch (ctx.getStatementSource()) {
47 return new EmptyUndeclaredInputStatement(ctx.coerceStatementArgument());
49 return new EmptyInputStatement(ctx.coerceStatementArgument());
51 throw new IllegalStateException("Unhandled statement source " + source);
56 protected final InputEffectiveStatement createDeclaredEffective(final int flags,
57 final StmtContext<QName, InputStatement, InputEffectiveStatement> ctx,
58 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
59 final InputStatement declared) {
60 return new DeclaredInputEffectiveStatement(declared, flags, ctx, substatements);
64 protected final InputEffectiveStatement createUndeclaredEffective(final int flags,
65 final StmtContext<QName, InputStatement, InputEffectiveStatement> ctx,
66 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
67 return new UndeclaredInputEffectiveStatement(flags, ctx, substatements);