2 * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.status;
10 import org.opendaylight.yangtools.yang.model.api.Status;
11 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
12 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
13 import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
17 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
19 public final class StatusStatementSupport
20 extends AbstractStatementSupport<Status, StatusStatement, EffectiveStatement<Status, StatusStatement>> {
21 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
25 public StatusStatementSupport() {
26 super(YangStmtMapping.STATUS);
30 public Status parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
33 return Status.CURRENT;
35 return Status.DEPRECATED;
37 return Status.OBSOLETE;
39 throw new SourceException(ctx.getStatementSourceReference(),
40 "Invalid status '%s', must be one of 'current', 'deprecated' or 'obsolete'", value);
45 public StatusStatement createDeclared(
46 final StmtContext<Status, StatusStatement, ?> ctx) {
47 return new StatusStatementImpl(ctx);
51 public EffectiveStatement<Status, StatusStatement> createEffective(
52 final StmtContext<Status, StatusStatement, EffectiveStatement<Status, StatusStatement>> ctx) {
53 return new StatusEffectiveStatementImpl(ctx);
57 public String internArgument(final String rawArgument) {
58 if ("current".equals(rawArgument)) {
60 } else if ("deprecated".equals(rawArgument)) {
62 } else if ("obsolete".equals(rawArgument)) {
70 protected SubstatementValidator getSubstatementValidator() {
71 return SUBSTATEMENT_VALIDATOR;