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.Deviation;
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<Deviation.Deviate> 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(
38 StmtContext<Deviation.Deviate, DeviateStatement, ?> context) {
42 public static class Definition extends AbstractStatementSupport<Deviation.Deviate, DeviateStatement,
43 EffectiveStatement<Deviation.Deviate, DeviateStatement>> {
46 super(Rfc6020Mapping.DEVIATE);
49 @Override public Deviation.Deviate parseArgumentValue(
50 StmtContext<?, ?, ?> ctx, String value) {
51 return Utils.parseDeviateFromString(ctx, value);
54 @Override public DeviateStatement createDeclared(
55 StmtContext<Deviation.Deviate, DeviateStatement, ?> ctx) {
56 return new DeviateStatementImpl(ctx);
59 @Override public EffectiveStatement<Deviation.Deviate, DeviateStatement> createEffective(
60 StmtContext<Deviation.Deviate, DeviateStatement, EffectiveStatement<Deviation.Deviate,
61 DeviateStatement>> ctx) {
62 return new DeviateEffectiveStatementImpl(ctx);
66 public void onFullDefinitionDeclared(StmtContext.Mutable<Deviation.Deviate, DeviateStatement,
67 EffectiveStatement<Deviation.Deviate, DeviateStatement>> stmt) {
68 super.onFullDefinitionDeclared(stmt);
69 SUBSTATEMENT_VALIDATOR.validate(stmt);
74 public Deviation.Deviate getValue() {