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.stmt.rfc6020.effective.FeatureEffectiveStatementImpl;
27 public class FeatureStatementImpl extends AbstractDeclaredStatement<QName>
28 implements FeatureStatement {
29 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
31 .add(Rfc6020Mapping.DESCRIPTION, 0, 1)
32 .add(Rfc6020Mapping.IF_FEATURE, 0, MAX)
33 .add(Rfc6020Mapping.STATUS, 0, 1)
34 .add(Rfc6020Mapping.REFERENCE, 0, 1)
37 protected FeatureStatementImpl(
38 StmtContext<QName, FeatureStatement, ?> context) {
42 public static class Definition
44 AbstractStatementSupport<QName, FeatureStatement, EffectiveStatement<QName, FeatureStatement>> {
47 super(Rfc6020Mapping.FEATURE);
51 public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
52 return Utils.qNameFromArgument(ctx, value);
56 public FeatureStatement createDeclared(
57 StmtContext<QName, FeatureStatement, ?> ctx) {
58 return new FeatureStatementImpl(ctx);
62 public EffectiveStatement<QName, FeatureStatement> createEffective(
63 StmtContext<QName, FeatureStatement, EffectiveStatement<QName, FeatureStatement>> ctx) {
64 return new FeatureEffectiveStatementImpl(ctx);
68 public void onFullDefinitionDeclared(StmtContext.Mutable<QName, FeatureStatement,
69 EffectiveStatement<QName, FeatureStatement>> stmt) {
70 super.onFullDefinitionDeclared(stmt);
71 SUBSTATEMENT_VALIDATOR.validate(stmt);
76 public StatusStatement getStatus() {
77 return firstDeclared(StatusStatement.class);
81 public DescriptionStatement getDescription() {
82 return firstDeclared(DescriptionStatement.class);
86 public ReferenceStatement getReference() {
87 return firstDeclared(ReferenceStatement.class);
91 public Collection<? extends IfFeatureStatement> getIfFeatures() {
92 return allDeclared(IfFeatureStatement.class);
96 public QName getName() {