2 * Copyright (c) 2015 Cisco Systems, Inc. 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.stmt.rfc6020;
10 import javax.annotation.Nonnull;
11 import org.opendaylight.yangtools.yang.model.api.Status;
12 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
15 import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
20 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.StatusEffectiveStatementImpl;
22 public class StatusStatementImpl extends AbstractDeclaredStatement<Status>
23 implements StatusStatement {
24 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
28 protected StatusStatementImpl(
29 final StmtContext<Status, StatusStatement, ?> context) {
33 public static class Definition
35 AbstractStatementSupport<Status, StatusStatement, EffectiveStatement<Status, StatusStatement>> {
38 super(YangStmtMapping.STATUS);
42 public Status parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
45 return Status.CURRENT;
47 return Status.DEPRECATED;
49 return Status.OBSOLETE;
51 throw new SourceException(ctx.getStatementSourceReference(),
52 "Invalid status '%s', must be one of 'current', 'deprecated' or 'obsolete'", value);
57 public StatusStatement createDeclared(
58 final StmtContext<Status, StatusStatement, ?> ctx) {
59 return new StatusStatementImpl(ctx);
63 public EffectiveStatement<Status, StatusStatement> createEffective(
64 final StmtContext<Status, StatusStatement, EffectiveStatement<Status, StatusStatement>> ctx) {
65 return new StatusEffectiveStatementImpl(ctx);
69 public String internArgument(final String rawArgument) {
70 if ("current".equals(rawArgument)) {
72 } else if ("deprecated".equals(rawArgument)) {
74 } else if ("obsolete".equals(rawArgument)) {
82 protected SubstatementValidator getSubstatementValidator() {
83 return SUBSTATEMENT_VALIDATOR;
89 public Status getValue() {