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 static org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator.MAX;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.yangtools.yang.model.api.DeviateKind;
14 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
15 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.DeviateStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeviateEffectiveStatementImpl;
23 public class DeviateStatementImpl extends AbstractDeclaredStatement<DeviateKind> implements DeviateStatement {
24 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
26 .add(Rfc6020Mapping.CONFIG, 0, 1)
27 .add(Rfc6020Mapping.DEFAULT, 0, 1)
28 .add(Rfc6020Mapping.MANDATORY, 0, 1)
29 .add(Rfc6020Mapping.MAX_ELEMENTS, 0, 1)
30 .add(Rfc6020Mapping.MIN_ELEMENTS, 0, 1)
31 .add(Rfc6020Mapping.MUST, 0, MAX)
32 .add(Rfc6020Mapping.TYPE, 0, 1)
33 .add(Rfc6020Mapping.UNIQUE, 0, MAX)
34 .add(Rfc6020Mapping.UNITS, 0, 1)
37 protected DeviateStatementImpl(StmtContext<DeviateKind, DeviateStatement, ?> context) {
41 public static class Definition extends AbstractStatementSupport<DeviateKind, DeviateStatement,
42 EffectiveStatement<DeviateKind, DeviateStatement>> {
45 super(Rfc6020Mapping.DEVIATE);
48 @Override public DeviateKind parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
49 return Utils.parseDeviateFromString(ctx, value);
52 @Override public DeviateStatement createDeclared(StmtContext<DeviateKind, DeviateStatement, ?> ctx) {
53 return new DeviateStatementImpl(ctx);
56 @Override public EffectiveStatement<DeviateKind, DeviateStatement> createEffective(
57 StmtContext<DeviateKind, DeviateStatement, EffectiveStatement<DeviateKind,
58 DeviateStatement>> ctx) {
59 return new DeviateEffectiveStatementImpl(ctx);
63 public void onFullDefinitionDeclared(StmtContext.Mutable<DeviateKind, DeviateStatement,
64 EffectiveStatement<DeviateKind, DeviateStatement>> stmt) {
65 super.onFullDefinitionDeclared(stmt);
66 SUBSTATEMENT_VALIDATOR.validate(stmt);
71 public DeviateKind getValue() {