2 * Copyright (c) 2020 PANTHEON.tech, 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;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
13 import com.google.common.collect.ImmutableList;
14 import java.util.function.Function;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.common.QNameModule;
18 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
19 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
21 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
27 * Specialization of {@link BaseQNameStatementSupport} for {@code input} and {@code output} statements.
29 * @param <D> Declared Statement representation
30 * @param <E> Effective Statement representation
33 public abstract class BaseOperationContainerStatementSupport<D extends DeclaredStatement<QName>,
34 E extends SchemaTreeEffectiveStatement<D>> extends BaseImplicitStatementSupport<D, E> {
35 private final Function<QNameModule, QName> createArgument;
37 protected BaseOperationContainerStatementSupport(final StatementDefinition publicDefinition,
38 final Function<QNameModule, QName> createArgument) {
39 super(publicDefinition);
40 this.createArgument = requireNonNull(createArgument);
44 public final QName parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
45 return createArgument.apply(StmtContextUtils.getRootModuleQName(ctx));
49 protected final @NonNull E createDeclaredEffective(final Current<QName, D> stmt,
50 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
51 return createDeclaredEffective(historyAndStatusFlags(stmt.history(), substatements), stmt, substatements);
54 protected abstract @NonNull E createDeclaredEffective(int flags, @NonNull Current<QName, D> stmt,
55 @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements);
58 protected final E createUndeclaredEffective(final Current<QName, D> stmt,
59 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
60 return createUndeclaredEffective(historyAndStatusFlags(stmt.history(), substatements), stmt, substatements);
63 protected abstract @NonNull E createUndeclaredEffective(int flags, @NonNull Current<QName, D> stmt,
64 @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements);