Remove yang.binding.RpcService
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / StatementNamespace.java
index 12dcdaceb5ddf8e7ef59e4fa8f74b1ebf9296260..f25df47efa0055dfbfff1d4937596c77f044037a 100644 (file)
@@ -7,10 +7,11 @@
  */
 package org.opendaylight.mdsal.binding.generator.impl.reactor;
 
-import static com.google.common.base.Verify.verifyNotNull;
+import static com.google.common.base.Verify.verify;
 import static java.util.Objects.requireNonNull;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
 
 /**
  * <a href="https://www.rfc-editor.org/rfc/rfc6020#section-6.2.1">YANG statement namespaces</a> which we process.
@@ -40,21 +41,90 @@ enum StatementNamespace {
      */
     YANG_DATA("$YD"),
     /**
-     * All other processed statements. Includes {@code augment}, and {@code schema tree} statements.
+     * The namespace for {@code augment} statements. These are specific to Java Binding.
      */
-    // FIXME: peel augment into "$A", which our own thing
-    // FIXME: add "$D" to disambiguate <module-name>Data
-    // FIXME: add "$L" to disambiguate <module-name>Listener
-    // FIXME: add "$S" to disambiguate <module-name>Service
-    DEFAULT("");
+    AUGMENT("$AU", true),
+    ACTION("$AC", true),
+    ANYDATA("$AD", true),
+    ANYXML("$AX", true),
+    CASE("$CA", true),
+    CHOICE("$CH", true),
+    CONTAINER("$CO", true),
+    INPUT("$IP", true),
+    LEAF("$LE", true),
+    LIST("$LI", true),
+    LEAF_LIST("$LL", true),
+    /**
+     * The namespace for a {@code list}'s {@code key} statement. This typically does not conflict, but could in case of
+     * <code>
+     *   <pre>
+     *     module foo {
+     *       list foo { // results Foo
+     *         key bar;  // triggers FooKey as a sibling to Foo
+     *         leaf bar {
+     *           type string;
+     *         }
+     *       }
+     *
+     *       container foo-key; // results in FooKey
+     *     }
+     *   </pre>
+     * </code>
+     * In this case the key-derived FooKey gets shifted to {@code $KE}.
+     */
+    KEY("$KE", true),
+    NOTIFICATION("$NO", true),
+    OUTPUT("$OU", true),
+    RPC("$RP", true),
+    /**
+     * The namespace for a {@code module}'s data root interface. This typically does not conflict, but could in case of
+     * <code>
+     *   <pre>
+     *     module foo { // results in FooData
+     *       container foo-data; // results in FooData as well
+     *     }
+     *   </pre>
+     * </code>
+     * In this case the module-derived FooData gets shifted to {@code $D}.
+     */
+    DATA_ROOT("$D", true),
+    /**
+     * The namespace for combined {@link NotificationListener} interface. This typically does not conflict, but could in
+     * case of
+     * <code>
+     *   <pre>
+     *     module foo {
+     *       container foo-listener; // results in FooListener
+     *       notification bar; // Triggers FooListener generation for module
+     *     }
+     *   </pre>
+     * </code>
+     * In this case the module-derived FooListener gets shifted to {@code $LL}.
+     *
+     * @deprecated This will be removed once {@link NotificationServiceGenerator} is gone.
+     */
+    // FIXME: MDSAL-497: remove this value
+    @Deprecated
+    NOTIFICATION_LISTENER("$LL", true);
 
     private final @NonNull String suffix;
+    private final boolean resistant;
 
     StatementNamespace(final @NonNull String suffix) {
+        this(suffix, false);
+    }
+
+    StatementNamespace(final @NonNull String suffix, final boolean resistant) {
+        verify(!suffix.isEmpty());
         this.suffix = requireNonNull(suffix);
+        this.resistant = resistant;
+    }
+
+    @NonNull String suffix() {
+        return suffix;
     }
 
-    @NonNull String appendSuffix(final String str) {
-        return suffix.isEmpty() ? verifyNotNull(str) : str + suffix;
+    boolean resistant() {
+        return resistant;
     }
 }