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 / NotificationStatementImpl.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.NotificationEffectiveStatementImpl;
11
12 import javax.annotation.Nullable;
13 import java.util.Collection;
14 import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
20 import org.opendaylight.yangtools.yang.common.QName;
21 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
22 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
23 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationStatement;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
26 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
27
28 public class NotificationStatementImpl extends AbstractDeclaredStatement<QName>
29         implements NotificationStatement {
30
31     protected NotificationStatementImpl(
32             StmtContext<QName, NotificationStatement, ?> context) {
33         super(context);
34     }
35
36     public static class Definition
37             extends
38             AbstractStatementSupport<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> {
39
40         public Definition() {
41             super(Rfc6020Mapping.NOTIFICATION);
42         }
43
44         @Override
45         public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
46             return Utils.qNameFromArgument(ctx, value);
47         }
48
49         @Override
50         public NotificationStatement createDeclared(
51                 StmtContext<QName, NotificationStatement, ?> ctx) {
52             return new NotificationStatementImpl(ctx);
53         }
54
55         @Override
56         public EffectiveStatement<QName, NotificationStatement> createEffective(
57                 StmtContext<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> ctx) {
58             return new NotificationEffectiveStatementImpl(ctx);
59         }
60
61     }
62
63     @Override
64     public QName getName() {
65         return argument();
66     }
67
68     @Override
69     public Collection<? extends TypedefStatement> getTypedefs() {
70         return allDeclared(TypedefStatement.class);
71     }
72
73     @Override
74     public Collection<? extends GroupingStatement> getGroupings() {
75         return allDeclared(GroupingStatement.class);
76     }
77
78     @Override
79     public Collection<? extends DataDefinitionStatement> getDataDefinitions() {
80         return allDeclared(DataDefinitionStatement.class);
81     }
82
83     @Nullable
84     @Override
85     public StatusStatement getStatus() {
86         return firstDeclared(StatusStatement.class);
87     }
88
89     @Nullable
90     @Override
91     public DescriptionStatement getDescription() {
92         return firstDeclared(DescriptionStatement.class);
93     }
94
95     @Nullable
96     @Override
97     public ReferenceStatement getReference() {
98         return firstDeclared(ReferenceStatement.class);
99     }
100 }