BUG-4638: Convert to using new types
[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 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
28
29 public class NotificationStatementImpl extends AbstractDeclaredStatement<QName>
30         implements NotificationStatement {
31
32     protected NotificationStatementImpl(
33             StmtContext<QName, NotificationStatement, ?> context) {
34         super(context);
35     }
36
37     public static class Definition
38             extends
39             AbstractStatementSupport<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> {
40
41         public Definition() {
42             super(Rfc6020Mapping.NOTIFICATION);
43         }
44
45         @Override
46         public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
47             return Utils.qNameFromArgument(ctx, value);
48         }
49
50         @Override
51         public void onStatementAdded(
52                 Mutable<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> stmt) {
53             stmt.getParentContext().addToNs(ChildSchemaNodes.class, stmt.getStatementArgument(), stmt);
54         }
55
56         @Override
57         public NotificationStatement createDeclared(
58                 StmtContext<QName, NotificationStatement, ?> ctx) {
59             return new NotificationStatementImpl(ctx);
60         }
61
62         @Override
63         public EffectiveStatement<QName, NotificationStatement> createEffective(
64                 StmtContext<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> ctx) {
65             return new NotificationEffectiveStatementImpl(ctx);
66         }
67
68     }
69
70     @Override
71     public QName getName() {
72         return argument();
73     }
74
75     @Override
76     public Collection<? extends TypedefStatement> getTypedefs() {
77         return allDeclared(TypedefStatement.class);
78     }
79
80     @Override
81     public Collection<? extends GroupingStatement> getGroupings() {
82         return allDeclared(GroupingStatement.class);
83     }
84
85     @Override
86     public Collection<? extends DataDefinitionStatement> getDataDefinitions() {
87         return allDeclared(DataDefinitionStatement.class);
88     }
89
90     @Nullable
91     @Override
92     public StatusStatement getStatus() {
93         return firstDeclared(StatusStatement.class);
94     }
95
96     @Nullable
97     @Override
98     public DescriptionStatement getDescription() {
99         return firstDeclared(DescriptionStatement.class);
100     }
101
102     @Nullable
103     @Override
104     public ReferenceStatement getReference() {
105         return firstDeclared(ReferenceStatement.class);
106     }
107 }