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
24 private static final StatusStatementSupport INSTANCE = new StatusStatementSupport();
26 private StatusStatementSupport() {
27 super(YangStmtMapping.STATUS);
30 public static StatusStatementSupport getInstance() {
35 public Status parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
38 return Status.CURRENT;
40 return Status.DEPRECATED;
42 return Status.OBSOLETE;
44 throw new SourceException(ctx.getStatementSourceReference(),
45 "Invalid status '%s', must be one of 'current', 'deprecated' or 'obsolete'", value);
50 public StatusStatement createDeclared(
51 final StmtContext<Status, StatusStatement, ?> ctx) {
52 return new StatusStatementImpl(ctx);
56 public EffectiveStatement<Status, StatusStatement> createEffective(
57 final StmtContext<Status, StatusStatement, EffectiveStatement<Status, StatusStatement>> ctx) {
58 return new StatusEffectiveStatementImpl(ctx);
62 public String internArgument(final String rawArgument) {
63 if ("current".equals(rawArgument)) {
65 } else if ("deprecated".equals(rawArgument)) {
67 } else if ("obsolete".equals(rawArgument)) {
75 protected SubstatementValidator getSubstatementValidator() {
76 return SUBSTATEMENT_VALIDATOR;