*/
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();
private PositionStatementSupport() {
- super(YangStmtMapping.POSITION);
+ super(YangStmtMapping.POSITION, StatementPolicy.contextIndependent());
}
public static PositionStatementSupport getInstance() {
}
@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) {
- throw new SourceException(String.format("Bit position value %s is not valid integer", value),
- ctx.getStatementSourceReference(), e);
+ return Uint32.valueOf(value).intern();
+ } catch (IllegalArgumentException e) {
+ throw new SourceException(ctx, e, "Bit position value %s is not valid integer", value);
}
}
@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 createEffective(final PositionStatement declared,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ return new RegularPositionEffectiveStatement(declared, substatements);
+ }
+
+ @Override
+ protected PositionEffectiveStatement createEmptyEffective(final PositionStatement declared) {
+ return new EmptyPositionEffectiveStatement(declared);
}
}
\ No newline at end of file