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.output;
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.OutputEffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.OutputStatement;
19 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseOperationContainerStatementSupport;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
23 abstract class AbstractOutputStatementSupport
24 extends BaseOperationContainerStatementSupport<OutputStatement, OutputEffectiveStatement> {
25 AbstractOutputStatementSupport() {
26 super(YangStmtMapping.OUTPUT, YangConstants::operationOutputQName);
30 protected final OutputStatement createDeclared(final StmtContext<QName, OutputStatement, ?> ctx,
31 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
32 final StatementSource source = ctx.source();
35 return new RegularUndeclaredOutputStatement(ctx.getArgument(), substatements);
37 return new RegularOutputStatement(ctx.getArgument(), substatements);
39 throw new IllegalStateException("Unhandled statement source " + source);
44 protected final OutputStatement createEmptyDeclared(final StmtContext<QName, OutputStatement, ?> ctx) {
45 final StatementSource source = ctx.source();
48 return new EmptyUndeclaredOutputStatement(ctx.getArgument());
50 return new EmptyOutputStatement(ctx.getArgument());
52 throw new IllegalStateException("Unhandled statement source " + source);
57 protected final OutputEffectiveStatement createDeclaredEffective(final int flags,
58 final Current<QName, OutputStatement> stmt,
59 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
60 return new DeclaredOutputEffectiveStatement(flags, stmt.declared(), substatements, stmt.sourceReference(),
61 stmt.getSchemaPath());
65 protected final OutputEffectiveStatement createUndeclaredEffective(final int flags,
66 final Current<QName, OutputStatement> stmt,
67 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
68 return new UndeclaredOutputEffectiveStatement(flags, substatements, stmt.sourceReference(),
69 stmt.getSchemaPath());