import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.UnionSpecification;
import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
import org.opendaylight.yangtools.yang.model.util.type.UnionTypeBuilder;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStringStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.CommonStmtCtx;
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.source.SourceException;
final class UnionSpecificationSupport
- extends BaseStatementSupport<String, UnionSpecification, EffectiveStatement<String, UnionSpecification>> {
+ extends AbstractStringStatementSupport<UnionSpecification, EffectiveStatement<String, UnionSpecification>> {
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
.TYPE)
.addMultiple(YangStmtMapping.TYPE)
.build();
UnionSpecificationSupport() {
- super(YangStmtMapping.TYPE);
- }
-
- @Override
- public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
- return value;
+ super(YangStmtMapping.TYPE, StatementPolicy.exactReplica());
}
@Override
@Override
protected UnionSpecification createDeclared(final StmtContext<String, UnionSpecification, ?> ctx,
final ImmutableList<? extends DeclaredStatement<?>> substatements) {
- return new UnionSpecificationImpl(ctx.coerceRawStatementArgument(), substatements);
+ return new UnionSpecificationImpl(ctx.getRawArgument(), substatements);
}
@Override
throw noType(stmt);
}
- final UnionTypeBuilder builder = BaseTypes.unionTypeBuilder(stmt.getSchemaPath());
+ final UnionTypeBuilder builder = BaseTypes.unionTypeBuilder(stmt.argumentAsTypeQName());
for (final EffectiveStatement<?, ?> subStmt : substatements) {
if (subStmt instanceof TypeEffectiveStatement) {
* When the type is "union", the "type" statement (Section 7.4) MUST be
* present.
*/
- return new SourceException("At least one type statement has to be present", stmt.sourceReference());
+ return new SourceException("At least one type statement has to be present", stmt);
}
}