*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.position;
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.common.Uint32;
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.PositionEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.PositionStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseInternedStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
public final class PositionStatementSupport
- extends AbstractStatementSupport<Long, PositionStatement, EffectiveStatement<Long, PositionStatement>> {
+ extends BaseInternedStatementSupport<Uint32, PositionStatement, PositionEffectiveStatement> {
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
YangStmtMapping.POSITION).build();
private static final PositionStatementSupport INSTANCE = new PositionStatementSupport();
}
@Override
- public Long parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
+ public Uint32 parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
try {
- return Long.parseLong(value);
- } catch (NumberFormatException e) {
+ return Uint32.valueOf(value).intern();
+ } catch (IllegalArgumentException e) {
throw new SourceException(String.format("Bit position value %s is not valid integer", value),
ctx.getStatementSourceReference(), e);
}
}
@Override
- public PositionStatement createDeclared(final StmtContext<Long, PositionStatement, ?> ctx) {
- return new PositionStatementImpl(ctx);
+ protected SubstatementValidator getSubstatementValidator() {
+ return SUBSTATEMENT_VALIDATOR;
}
@Override
- public EffectiveStatement<Long, PositionStatement> createEffective(
- final StmtContext<Long, PositionStatement, EffectiveStatement<Long, PositionStatement>> ctx) {
- return new PositionEffectiveStatementImpl(ctx);
+ protected PositionStatement createDeclared(final Uint32 argument,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ return new RegularPositionStatement(argument, substatements);
}
@Override
- protected SubstatementValidator getSubstatementValidator() {
- return SUBSTATEMENT_VALIDATOR;
+ protected PositionStatement createEmptyDeclared(final Uint32 argument) {
+ return new EmptyPositionStatement(argument);
+ }
+
+ @Override
+ protected PositionEffectiveStatement createEmptyEffective(final PositionStatement declared) {
+ return new EmptyPositionEffectiveStatement(declared);
+ }
+
+ @Override
+ protected PositionEffectiveStatement createEffective(
+ final StmtContext<Uint32, PositionStatement, PositionEffectiveStatement> ctx,
+ final PositionStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ return new RegularPositionEffectiveStatement(declared, substatements);
}
}
\ No newline at end of file