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 java.util.List;
11 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
12 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
13 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.LengthStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
18 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
19 import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
23 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.LengthEffectiveStatementImpl;
25 public class LengthStatementImpl extends AbstractDeclaredStatement<List<LengthConstraint>> implements LengthStatement {
26 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
28 .add(Rfc6020Mapping.DESCRIPTION, 0, 1)
29 .add(Rfc6020Mapping.ERROR_APP_TAG, 0, 1)
30 .add(Rfc6020Mapping.ERROR_MESSAGE, 0, 1)
31 .add(Rfc6020Mapping.REFERENCE, 0, 1)
34 protected LengthStatementImpl(StmtContext<List<LengthConstraint>, LengthStatement, ?> context) {
38 public static class Definition extends AbstractStatementSupport<List<LengthConstraint>, LengthStatement,
39 EffectiveStatement<List<LengthConstraint>, LengthStatement>> {
42 super(Rfc6020Mapping.LENGTH);
46 public List<LengthConstraint> parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
47 return TypeUtils.parseLengthListFromString(ctx, value);
51 public LengthStatement createDeclared(StmtContext<List<LengthConstraint>, LengthStatement, ?> ctx) {
52 return new LengthStatementImpl(ctx);
56 public EffectiveStatement<List<LengthConstraint>, LengthStatement> createEffective(
57 StmtContext<List<LengthConstraint>, LengthStatement, EffectiveStatement<List<LengthConstraint>,
58 LengthStatement>> ctx) {
59 return new LengthEffectiveStatementImpl(ctx);
63 public void onFullDefinitionDeclared(StmtContext.Mutable<List<LengthConstraint>,
64 LengthStatement, EffectiveStatement<List<LengthConstraint>, LengthStatement>> stmt) {
65 super.onFullDefinitionDeclared(stmt);
66 SUBSTATEMENT_VALIDATOR.validate(stmt);
71 public ErrorAppTagStatement getErrorAppTagStatement() {
72 return firstDeclared(ErrorAppTagStatement.class);
76 public ErrorMessageStatement getErrorMessageStatement() {
77 return firstDeclared(ErrorMessageStatement.class);
81 public DescriptionStatement getDescription() {
82 return firstDeclared(DescriptionStatement.class);
86 public ReferenceStatement getReference() {
87 return firstDeclared(ReferenceStatement.class);
91 public List<LengthConstraint> getValue() {