Bug 2366 - Effective statements impl for new yang parser.
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / FeatureStatementImpl.java
1 /**
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
9
10 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.FeatureEffectiveStatementImpl;
11
12 import java.util.Collection;
13 import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
16 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
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.meta.AbstractDeclaredStatement;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
24
25 public class FeatureStatementImpl extends AbstractDeclaredStatement<QName>
26         implements FeatureStatement {
27
28     protected FeatureStatementImpl(
29             StmtContext<QName, FeatureStatement, ?> context) {
30         super(context);
31     }
32
33     public static class Definition
34             extends
35             AbstractStatementSupport<QName, FeatureStatement, EffectiveStatement<QName, FeatureStatement>> {
36
37         public Definition() {
38             super(Rfc6020Mapping.FEATURE);
39         }
40
41         @Override
42         public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
43             return Utils.qNameFromArgument(ctx, value);
44         }
45
46         @Override
47         public FeatureStatement createDeclared(
48                 StmtContext<QName, FeatureStatement, ?> ctx) {
49             return new FeatureStatementImpl(ctx);
50         }
51
52         @Override
53         public EffectiveStatement<QName, FeatureStatement> createEffective(
54                 StmtContext<QName, FeatureStatement, EffectiveStatement<QName, FeatureStatement>> ctx) {
55             return new FeatureEffectiveStatementImpl(ctx);
56         }
57
58     }
59
60     @Override
61     public StatusStatement getStatus() {
62         return firstDeclared(StatusStatement.class);
63     }
64
65     @Override
66     public DescriptionStatement getDescription() {
67         return firstDeclared(DescriptionStatement.class);
68     }
69
70     @Override
71     public ReferenceStatement getReference() {
72         return firstDeclared(ReferenceStatement.class);
73     }
74
75     @Override
76     public Collection<? extends IfFeatureStatement> getIfFeatures() {
77         return allDeclared(IfFeatureStatement.class);
78     }
79
80     @Override
81     public QName getName() {
82         return argument();
83     }
84
85 }