*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
+import java.util.function.Function;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
/**
* Specialization of {@link BaseQNameStatementSupport} for {@code input} and {@code output} statements.
@Beta
public abstract class BaseOperationContainerStatementSupport<D extends DeclaredStatement<QName>,
E extends SchemaTreeEffectiveStatement<D>> extends BaseImplicitStatementSupport<D, E> {
- protected BaseOperationContainerStatementSupport(final StatementDefinition publicDefinition) {
- super(publicDefinition);
+ private final Function<QNameModule, QName> createArgument;
+
+ protected BaseOperationContainerStatementSupport(final StatementDefinition publicDefinition,
+ final Function<QNameModule, QName> createArgument, final CopyPolicy copyPolicy) {
+ super(publicDefinition, copyPolicy);
+ this.createArgument = requireNonNull(createArgument);
}
@Override
- protected final @NonNull E createDeclaredEffective(final StmtContext<QName, D, E> ctx,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final D declared) {
- return createDeclaredEffective(historyAndStatusFlags(ctx, substatements), ctx, substatements, declared);
+ public final QName parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
+ return createArgument.apply(StmtContextUtils.getRootModuleQName(ctx));
}
- protected abstract @NonNull E createDeclaredEffective(int flags, @NonNull StmtContext<QName, D, E> ctx,
- @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements, @NonNull D declared);
+ @Override
+ protected final @NonNull E createDeclaredEffective(final Current<QName, D> stmt,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ try {
+ return createDeclaredEffective(historyAndStatusFlags(stmt.history(), substatements), stmt, substatements);
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt, e);
+ }
+ }
+
+ protected abstract @NonNull E createDeclaredEffective(int flags, @NonNull Current<QName, D> stmt,
+ @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements);
@Override
- protected final E createUndeclaredEffective(final StmtContext<QName, D, E> ctx,
+ protected final E createUndeclaredEffective(final Current<QName, D> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return createUndeclaredEffective(historyAndStatusFlags(ctx, substatements), ctx, substatements);
+ return createUndeclaredEffective(historyAndStatusFlags(stmt.history(), substatements), stmt, substatements);
}
- protected abstract @NonNull E createUndeclaredEffective(int flags, @NonNull StmtContext<QName, D, E> ctx,
+ protected abstract @NonNull E createUndeclaredEffective(int flags, @NonNull Current<QName, D> stmt,
@NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements);
}