Add DataNodeContainer.dataChildByName() 21/94321/1
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 6 Dec 2020 13:05:18 +0000 (14:05 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 31 Dec 2020 13:22:45 +0000 (14:22 +0100)
This is a non-deprecated equivalent of getDataChildByName(), allowing
easy migration of nullable users.

JIRA: YANGTOOLS-1183`
Change-Id: Iaf2336fdbfb6533fe759ea4a359b7458e20c79fe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7574750a4555d7cb0bcd127b5e5e43a9aecb7d00)

yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DataNodeContainer.java

index 658d40829328d9cd2c892e1e47ff2c7e61ebbffd..748d004895d56663443d0cb558b6329d1f845f77 100644 (file)
@@ -60,14 +60,31 @@ public interface DataNodeContainer {
      *
      * @param name QName of child
      * @return child node of this DataNodeContainer if child with given name is present, null otherwise
-     * @deprecated Use {@link #findDataChildByName(QName)} instead.
      * @throws NullPointerException if {@code name} is null
      */
-    @Deprecated
-    default @Nullable DataSchemaNode getDataChildByName(final QName name) {
+    default @Nullable DataSchemaNode dataChildByName(final QName name) {
         return findDataChildByName(name).orElse(null);
     }
 
+    /**
+     * Returns the child node corresponding to the specified name.
+     *
+     * <p>
+     * Note that the nodes searched are <strong>NOT</strong> {@code data nodes}, but rather {@link DataSchemaNode}s,
+     * hence {@link ChoiceSchemaNode} and {@link CaseSchemaNode} are returned instead of their matching children. This
+     * is consistent with {@code schema tree}.
+     *
+     * @param name QName of child
+     * @return child node of this DataNodeContainer if child with given name is present, null otherwise
+     * @deprecated Use {@link #dataChildByName(QName)} or {@link #findDataChildByName(QName)} instead. This method will
+     *             be repurposed to assert existence in the next major release.
+     * @throws NullPointerException if {@code name} is null
+     */
+    @Deprecated(forRemoval = true)
+    default @Nullable DataSchemaNode getDataChildByName(final QName name) {
+        return dataChildByName(name);
+    }
+
     /**
      * Returns the child node corresponding to the specified name.
      *