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.ReferenceEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
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 ReferenceStatement createDeclared(final StmtContext<String, ReferenceStatement, ?> ctx) {
- return new ReferenceStatementImpl(ctx);
+ protected ReferenceStatement createDeclared(final StmtContext<String, ReferenceStatement, ?> ctx,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ return new RegularReferenceStatement(ctx.coerceRawStatementArgument(), substatements);
}
@Override
- protected SubstatementValidator getSubstatementValidator() {
- return SUBSTATEMENT_VALIDATOR;
+ protected ReferenceStatement createEmptyDeclared(final StmtContext<String, ReferenceStatement, ?> ctx) {
+ return new EmptyReferenceStatement(ctx.coerceRawStatementArgument());
}
@Override
- protected ReferenceEffectiveStatement createEffective(
- final StmtContext<String, ReferenceStatement, ReferenceEffectiveStatement> ctx,
- final ReferenceStatement declared,
+ protected ReferenceEffectiveStatement createEffective(final Current<String, ReferenceStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new RegularReferenceEffectiveStatement(declared, substatements);
- }
-
- @Override
- protected ReferenceEffectiveStatement createEmptyEffective(
- final StmtContext<String, ReferenceStatement, ReferenceEffectiveStatement> ctx,
- final ReferenceStatement declared) {
- return new EmptyReferenceEffectiveStatement(declared);
+ return substatements.isEmpty() ? new EmptyReferenceEffectiveStatement(stmt.declared())
+ : new RegularReferenceEffectiveStatement(stmt.declared(), substatements);
}
-}
\ No newline at end of file
+}