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.Rfc6020Mapping;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.DeviationStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
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.spi.source.SourceException;
22 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeviationEffectiveStatementImpl;
24 public class DeviationStatementImpl extends AbstractDeclaredStatement<SchemaNodeIdentifier> implements DeviationStatement {
25 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
27 .add(Rfc6020Mapping.DESCRIPTION, 0, 1)
28 .add(Rfc6020Mapping.DEVIATE, 0, MAX)
29 .add(Rfc6020Mapping.REFERENCE, 0, 1)
32 protected DeviationStatementImpl(final StmtContext<SchemaNodeIdentifier, DeviationStatement, ?> context) {
36 public static class Definition extends AbstractStatementSupport<SchemaNodeIdentifier,DeviationStatement,EffectiveStatement<SchemaNodeIdentifier,DeviationStatement>> {
39 super(Rfc6020Mapping.DEVIATION);
43 public SchemaNodeIdentifier parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
44 return Utils.nodeIdentifierFromPath(ctx, value);
48 public DeviationStatement createDeclared(final StmtContext<SchemaNodeIdentifier, DeviationStatement, ?> ctx) {
49 return new DeviationStatementImpl(ctx);
53 public EffectiveStatement<SchemaNodeIdentifier, DeviationStatement> createEffective(
54 final StmtContext<SchemaNodeIdentifier, DeviationStatement, EffectiveStatement<SchemaNodeIdentifier, DeviationStatement>> ctx) {
55 return new DeviationEffectiveStatementImpl(ctx);
59 public void onFullDefinitionDeclared(StmtContext.Mutable<SchemaNodeIdentifier, DeviationStatement,
60 EffectiveStatement<SchemaNodeIdentifier, DeviationStatement>> stmt) throws SourceException {
61 super.onFullDefinitionDeclared(stmt);
62 SUBSTATEMENT_VALIDATOR.validate(stmt);
67 public SchemaNodeIdentifier getTargetNode() {