import org.opendaylight.yangtools.yang.model.api.stmt.DeviationEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.DeviationStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
+import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName;
public final class DeviationStatementSupport
- extends BaseStatementSupport<Absolute, DeviationStatement, DeviationEffectiveStatement> {
+ extends AbstractStatementSupport<Absolute, DeviationStatement, DeviationEffectiveStatement> {
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
.DEVIATION)
.addOptional(YangStmtMapping.DESCRIPTION)
private static final DeviationStatementSupport INSTANCE = new DeviationStatementSupport();
private DeviationStatementSupport() {
- super(YangStmtMapping.DEVIATION);
+ super(YangStmtMapping.DEVIATION, StatementPolicy.reject());
}
public static DeviationStatementSupport getInstance() {
@Override
public void onFullDefinitionDeclared(
final Mutable<Absolute, DeviationStatement, DeviationEffectiveStatement> ctx) {
- final QNameModule currentModule = ctx.getFromNamespace(ModuleCtxToModuleQName.class,
- ctx.getRoot());
- final QNameModule targetModule = Iterables.getLast(ctx.coerceStatementArgument().getNodeIdentifiers())
- .getModule();
+ final QNameModule currentModule = ctx.getFromNamespace(ModuleCtxToModuleQName.class, ctx.getRoot());
+ final QNameModule targetModule = Iterables.getLast(ctx.getArgument().getNodeIdentifiers()).getModule();
if (currentModule.equals(targetModule)) {
- throw new InferenceException(ctx.getStatementSourceReference(),
+ throw new InferenceException(ctx,
"Deviation must not target the same module as the one it is defined in: %s", currentModule);
}
}
@Override
protected DeviationStatement createDeclared(final StmtContext<Absolute, DeviationStatement, ?> ctx,
final ImmutableList<? extends DeclaredStatement<?>> substatements) {
- return new DeviationStatementImpl(ctx, substatements);
+ return DeclaredStatements.createDeviation(ctx.getRawArgument(), ctx.getArgument(), substatements);
}
@Override
- protected DeviationStatement createEmptyDeclared(
- final StmtContext<Absolute, DeviationStatement, ?> ctx) {
- return new DeviationStatementImpl(ctx, ImmutableList.of());
+ protected DeviationStatement createEmptyDeclared(final StmtContext<Absolute, DeviationStatement, ?> ctx) {
+ return DeclaredStatements.createDeviation(ctx.getRawArgument(), ctx.getArgument());
}
@Override
- protected DeviationEffectiveStatement createEffective(
- final StmtContext<Absolute, DeviationStatement, DeviationEffectiveStatement> ctx,
- final DeviationStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new DeviationEffectiveStatementImpl(declared, substatements);
- }
-
- @Override
- protected DeviationEffectiveStatement createEmptyEffective(
- final StmtContext<Absolute, DeviationStatement, DeviationEffectiveStatement> ctx,
- final DeviationStatement declared) {
- return new DeviationEffectiveStatementImpl(declared, ImmutableList.of());
+ protected DeviationEffectiveStatement createEffective(final Current<Absolute, DeviationStatement> stmt,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ return new DeviationEffectiveStatementImpl(stmt.declared(), substatements);
}
}
\ No newline at end of file