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.rfc7950.stmt.SubstatementIndexingException;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
23 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
25 abstract class AbstractInputStatementSupport
26 extends BaseOperationContainerStatementSupport<InputStatement, InputEffectiveStatement> {
27 AbstractInputStatementSupport() {
28 super(YangStmtMapping.INPUT, YangConstants::operationInputQName);
32 protected final InputStatement createDeclared(final StmtContext<QName, InputStatement, ?> ctx,
33 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
34 final StatementSource source = ctx.source();
37 return new RegularUndeclaredInputStatement(ctx.getArgument(), substatements);
39 return new RegularInputStatement(ctx.getArgument(), substatements);
41 throw new IllegalStateException("Unhandled statement source " + source);
46 protected final InputStatement createEmptyDeclared(final StmtContext<QName, InputStatement, ?> ctx) {
47 final StatementSource source = ctx.source();
50 return new EmptyUndeclaredInputStatement(ctx.getArgument());
52 return new EmptyInputStatement(ctx.getArgument());
54 throw new IllegalStateException("Unhandled statement source " + source);
59 protected final InputEffectiveStatement createDeclaredEffective(final int flags,
60 final Current<QName, InputStatement> stmt,
61 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
62 return new DeclaredInputEffectiveStatement(flags, stmt.declared(), substatements, stmt.getSchemaPath());
66 protected final InputEffectiveStatement createUndeclaredEffective(final int flags,
67 final Current<QName, InputStatement> stmt,
68 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
70 return new UndeclaredInputEffectiveStatement(flags, substatements, stmt.getSchemaPath());
71 } catch (SubstatementIndexingException e) {
72 throw new SourceException(e.getMessage(), stmt.sourceReference(), e);