package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.description;
import com.google.common.collect.ImmutableList;
-import java.util.Optional;
-import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
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.stmt.DescriptionEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
-import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
+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.StmtContext.Mutable;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
public final class DescriptionStatementSupport
private static final DescriptionStatementSupport INSTANCE = new DescriptionStatementSupport();
private DescriptionStatementSupport() {
- super(YangStmtMapping.DESCRIPTION);
+ super(YangStmtMapping.DESCRIPTION, StatementPolicy.contextIndependent());
}
public static DescriptionStatementSupport getInstance() {
return INSTANCE;
}
- @Override
- public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
- return value;
- }
-
- @Override
- public Optional<? extends Mutable<?, ?, ?>> copyAsChildOf(final Mutable<?, ?, ?> stmt,
- final Mutable<?, ?, ?> parent, final CopyType type, final QNameModule targetModule) {
- return StmtContextUtils.isChildOfGrouping(stmt) ? Optional.empty()
- : super.copyAsChildOf(stmt, parent, type, targetModule);
- }
-
@Override
protected SubstatementValidator getSubstatementValidator() {
return SUBSTATEMENT_VALIDATOR;
@Override
protected DescriptionStatement createDeclared(final StmtContext<String, DescriptionStatement, ?> ctx,
final ImmutableList<? extends DeclaredStatement<?>> substatements) {
- return new RegularDescriptionStatement(ctx, substatements);
+ return new RegularDescriptionStatement(ctx.getRawArgument(), substatements);
}
@Override
protected DescriptionStatement createEmptyDeclared(final StmtContext<String, DescriptionStatement, ?> ctx) {
- return new EmptyDescriptionStatement(ctx);
+ return new EmptyDescriptionStatement(ctx.getRawArgument());
}
@Override
- protected DescriptionEffectiveStatement createEffective(
- final StmtContext<String, DescriptionStatement, DescriptionEffectiveStatement> ctx,
- final DescriptionStatement declared,
+ protected DescriptionEffectiveStatement createEffective(final Current<String, DescriptionStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new RegularDescriptionEffectiveStatement(declared, substatements);
- }
-
- @Override
- protected DescriptionEffectiveStatement createEmptyEffective(
- final StmtContext<String, DescriptionStatement, DescriptionEffectiveStatement> ctx,
- final DescriptionStatement declared) {
- return new EmptyDescriptionEffectiveStatement(declared);
+ return substatements.isEmpty() ? new EmptyDescriptionEffectiveStatement(stmt.declared())
+ : new RegularDescriptionEffectiveStatement(stmt.declared(), substatements);
}
}