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.position;
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.PositionStatement;
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 PositionStatementSupport
19 extends AbstractStatementSupport<Long, PositionStatement, EffectiveStatement<Long, PositionStatement>> {
20 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
21 YangStmtMapping.POSITION).build();
22 private static final PositionStatementSupport INSTANCE = new PositionStatementSupport();
24 private PositionStatementSupport() {
25 super(YangStmtMapping.POSITION);
28 public static PositionStatementSupport getInstance() {
33 public Long parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
35 return Long.parseLong(value);
36 } catch (NumberFormatException e) {
37 throw new SourceException(String.format("Bit position value %s is not valid integer", value),
38 ctx.getStatementSourceReference(), e);
43 public PositionStatement createDeclared(final StmtContext<Long, PositionStatement, ?> ctx) {
44 return new PositionStatementImpl(ctx);
48 public EffectiveStatement<Long, PositionStatement> createEffective(
49 final StmtContext<Long, PositionStatement, EffectiveStatement<Long, PositionStatement>> ctx) {
50 return new PositionEffectiveStatementImpl(ctx);
54 protected SubstatementValidator getSubstatementValidator() {
55 return SUBSTATEMENT_VALIDATOR;