*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
-import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
-import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
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;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.StatusEffectiveStatementImpl;
public class StatusStatementImpl extends AbstractDeclaredStatement<Status>
implements StatusStatement {
- private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
+ private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
.STATUS)
.build();
protected StatusStatementImpl(
- StmtContext<Status, StatusStatement, ?> context) {
+ final StmtContext<Status, StatusStatement, ?> context) {
super(context);
}
AbstractStatementSupport<Status, StatusStatement, EffectiveStatement<Status, StatusStatement>> {
public Definition() {
- super(Rfc6020Mapping.STATUS);
+ super(YangStmtMapping.STATUS);
}
@Override
- public Status parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
- return Utils.parseStatus(value);
+ public Status parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
+ switch (value) {
+ case "current":
+ return Status.CURRENT;
+ case "deprecated":
+ return Status.DEPRECATED;
+ case "obsolete":
+ return Status.OBSOLETE;
+ default:
+ throw new SourceException(ctx.getStatementSourceReference(),
+ "Invalid status '%s', must be one of 'current', 'deprecated' or 'obsolete'", value);
+ }
}
@Override
public StatusStatement createDeclared(
- StmtContext<Status, StatusStatement, ?> ctx) {
+ final StmtContext<Status, StatusStatement, ?> ctx) {
return new StatusStatementImpl(ctx);
}
@Override
public EffectiveStatement<Status, StatusStatement> createEffective(
- StmtContext<Status, StatusStatement, EffectiveStatement<Status, StatusStatement>> ctx) {
+ final StmtContext<Status, StatusStatement, EffectiveStatement<Status, StatusStatement>> ctx) {
return new StatusEffectiveStatementImpl(ctx);
}
@Override
- public void onFullDefinitionDeclared(StmtContext.Mutable<Status, StatusStatement,
- EffectiveStatement<Status, StatusStatement>> stmt) throws SourceException {
- super.onFullDefinitionDeclared(stmt);
- SUBSTATEMENT_VALIDATOR.validate(stmt);
+ public String internArgument(final String rawArgument) {
+ if ("current".equals(rawArgument)) {
+ return "current";
+ } else if ("deprecated".equals(rawArgument)) {
+ return "deprecated";
+ } else if ("obsolete".equals(rawArgument)) {
+ return "obsolete";
+ } else {
+ return rawArgument;
+ }
+ }
+
+ @Override
+ protected SubstatementValidator getSubstatementValidator() {
+ return SUBSTATEMENT_VALIDATOR;
}
}
+ @Nonnull
@Override
public Status getValue() {
return argument();