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 java.util.Collection;
13 import org.opendaylight.yangtools.yang.common.QName;
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.DescriptionStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
20 import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
21 import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
25 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
26 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.FeatureEffectiveStatementImpl;
28 public class FeatureStatementImpl extends AbstractDeclaredStatement<QName>
29 implements FeatureStatement {
30 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
32 .add(Rfc6020Mapping.DESCRIPTION, 0, 1)
33 .add(Rfc6020Mapping.IF_FEATURE, 0, MAX)
34 .add(Rfc6020Mapping.STATUS, 0, 1)
35 .add(Rfc6020Mapping.REFERENCE, 0, 1)
38 protected FeatureStatementImpl(
39 StmtContext<QName, FeatureStatement, ?> context) {
43 public static class Definition
45 AbstractStatementSupport<QName, FeatureStatement, EffectiveStatement<QName, FeatureStatement>> {
48 super(Rfc6020Mapping.FEATURE);
52 public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
53 return Utils.qNameFromArgument(ctx, value);
57 public FeatureStatement createDeclared(
58 StmtContext<QName, FeatureStatement, ?> ctx) {
59 return new FeatureStatementImpl(ctx);
63 public EffectiveStatement<QName, FeatureStatement> createEffective(
64 StmtContext<QName, FeatureStatement, EffectiveStatement<QName, FeatureStatement>> ctx) {
65 return new FeatureEffectiveStatementImpl(ctx);
69 public void onFullDefinitionDeclared(StmtContext.Mutable<QName, FeatureStatement,
70 EffectiveStatement<QName, FeatureStatement>> stmt) throws SourceException {
71 super.onFullDefinitionDeclared(stmt);
72 SUBSTATEMENT_VALIDATOR.validate(stmt);
77 public StatusStatement getStatus() {
78 return firstDeclared(StatusStatement.class);
82 public DescriptionStatement getDescription() {
83 return firstDeclared(DescriptionStatement.class);
87 public ReferenceStatement getReference() {
88 return firstDeclared(ReferenceStatement.class);
92 public Collection<? extends IfFeatureStatement> getIfFeatures() {
93 return allDeclared(IfFeatureStatement.class);
97 public QName getName() {