import com.google.common.collect.ImmutableList;
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.PresenceEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
+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.SubstatementValidator;
}
@Override
- public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
- return value;
+ protected SubstatementValidator getSubstatementValidator() {
+ return SUBSTATEMENT_VALIDATOR;
}
@Override
- public PresenceStatement createDeclared(final StmtContext<String, PresenceStatement, ?> ctx) {
- return new PresenceStatementImpl(ctx);
+ protected PresenceStatement createDeclared(final StmtContext<String, PresenceStatement, ?> ctx,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ return new RegularPresenceStatement(ctx.getRawArgument(), substatements);
}
@Override
- protected SubstatementValidator getSubstatementValidator() {
- return SUBSTATEMENT_VALIDATOR;
+ protected PresenceStatement createEmptyDeclared(final StmtContext<String, PresenceStatement, ?> ctx) {
+ return new EmptyPresenceStatement(ctx.getRawArgument());
}
@Override
- protected PresenceEffectiveStatement createEffective(
- final StmtContext<String, PresenceStatement, PresenceEffectiveStatement> ctx,
- final PresenceStatement declared,
+ protected PresenceEffectiveStatement createEffective(final Current<String, PresenceStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new RegularPresenceEffectiveStatement(declared, substatements);
- }
-
- @Override
- protected PresenceEffectiveStatement createEmptyEffective(
- final StmtContext<String, PresenceStatement, PresenceEffectiveStatement> ctx,
- final PresenceStatement declared) {
- return new EmptyPresenceEffectiveStatement(declared);
+ return substatements.isEmpty() ? new EmptyPresenceEffectiveStatement(stmt.declared())
+ : new RegularPresenceEffectiveStatement(stmt.declared(), substatements);
}
}
\ No newline at end of file