Remove support for composite NotificationListener
[yangtools.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / StatementNamespace.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. 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.mdsal.binding.generator.impl.reactor;
9
10 import static com.google.common.base.Verify.verify;
11 import static java.util.Objects.requireNonNull;
12
13 import org.eclipse.jdt.annotation.NonNull;
14
15 /**
16  * <a href="https://www.rfc-editor.org/rfc/rfc6020#section-6.2.1">YANG statement namespaces</a> which we process.
17  */
18 // FIXME: move this to 'BindingNamespace' in binding-spec-util
19 enum StatementNamespace {
20     /**
21      * The namespace of all {@code feature} statements, bullet 3.
22      */
23     FEATURE("$F"),
24     /**
25      * The namespace of all {@code identity} statements, bullet 4.
26      */
27     IDENTITY("$I"),
28     /**
29      * The namespace of all {@code typedef} statements, bullet 5.
30      */
31     TYPEDEF("$T"),
32     /**
33      * The namespace of all {@code grouping} statements, bullet 6.
34      */
35     GROUPING("$G"),
36     /**
37      * The namespace of all RFC8040 {@code ietf-restconf:yang-data} statements. These sit outside of the usual YANG
38      * statement namespaces, but may overlap in the usual case when template names conform to YANG {@code identifier}
39      * rules.
40      */
41     YANG_DATA("$YD"),
42     /**
43      * The namespace for {@code augment} statements. These are specific to Java Binding.
44      */
45     AUGMENT("$AU", true),
46     ACTION("$AC", true),
47     ANYDATA("$AD", true),
48     ANYXML("$AX", true),
49     CASE("$CA", true),
50     CHOICE("$CH", true),
51     CONTAINER("$CO", true),
52     INPUT("$IP", true),
53     LEAF("$LE", true),
54     LIST("$LI", true),
55     LEAF_LIST("$LL", true),
56     /**
57      * The namespace for a {@code list}'s {@code key} statement. This typically does not conflict, but could in case of
58      * <code>
59      *   <pre>
60      *     module foo {
61      *       list foo { // results Foo
62      *         key bar;  // triggers FooKey as a sibling to Foo
63      *         leaf bar {
64      *           type string;
65      *         }
66      *       }
67      *
68      *       container foo-key; // results in FooKey
69      *     }
70      *   </pre>
71      * </code>
72      * In this case the key-derived FooKey gets shifted to {@code $KE}.
73      */
74     KEY("$KE", true),
75     NOTIFICATION("$NO", true),
76     OUTPUT("$OU", true),
77     RPC("$RP", true),
78     /**
79      * The namespace for a {@code module}'s data root interface. This typically does not conflict, but could in case of
80      * <code>
81      *   <pre>
82      *     module foo { // results in FooData
83      *       container foo-data; // results in FooData as well
84      *     }
85      *   </pre>
86      * </code>
87      * In this case the module-derived FooData gets shifted to {@code $D}.
88      */
89     DATA_ROOT("$D", true);
90
91     private final @NonNull String suffix;
92     private final boolean resistant;
93
94     StatementNamespace(final @NonNull String suffix) {
95         this(suffix, false);
96     }
97
98     StatementNamespace(final @NonNull String suffix, final boolean resistant) {
99         verify(!suffix.isEmpty());
100         this.suffix = requireNonNull(suffix);
101         this.resistant = resistant;
102     }
103
104     @NonNull String suffix() {
105         return suffix;
106     }
107
108     boolean resistant() {
109         return resistant;
110     }
111 }