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.value;
10 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
11 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
12 import org.opendaylight.yangtools.yang.model.api.stmt.ValueStatement;
13 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
16 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
18 public final class ValueStatementSupport extends
19 AbstractStatementSupport<Integer, ValueStatement, EffectiveStatement<Integer, ValueStatement>> {
20 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
21 YangStmtMapping.VALUE).build();
23 public ValueStatementSupport() {
24 super(YangStmtMapping.VALUE);
28 public Integer parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
30 return Integer.valueOf(value);
31 } catch (NumberFormatException e) {
32 throw new SourceException(ctx.getStatementSourceReference(), e,
33 "%s is not valid value statement integer argument in a range of -2147483648..2147483647", value);
38 public ValueStatement createDeclared(final StmtContext<Integer, ValueStatement, ?> ctx) {
39 return new ValueStatementImpl(ctx);
43 public EffectiveStatement<Integer, ValueStatement> createEffective(
44 final StmtContext<Integer, ValueStatement, EffectiveStatement<Integer, ValueStatement>> ctx) {
45 return new ValueEffectiveStatementImpl(ctx);
49 protected SubstatementValidator getSubstatementValidator() {
50 return SUBSTATEMENT_VALIDATOR;