Introduce DataNodeContainer.findDataChildByName()
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / DataNodeContainer.java
index d07be7d64d8586a0cd3f8fd5c7af7f4aa0f5b262..308697a7cffd28aadf4f7070a94348d0db6e8e23 100644 (file)
@@ -8,7 +8,9 @@
 package org.opendaylight.yangtools.yang.model.api;
 
 import java.util.Collection;
+import java.util.Optional;
 import java.util.Set;
+import javax.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QName;
 
 /**
@@ -44,10 +46,24 @@ public interface DataNodeContainer {
      *
      * @param name
      *            QName of child
-     * @return child node of this DataNodeContainer if child with given name is
-     *         present, null otherwise
+     * @return child node of this DataNodeContainer if child with given name is present, null otherwise
+     *
+     * @deprecated Use {@link #findDataChildByName(QName)} instead.
+     */
+    @Deprecated
+    @Nullable default DataSchemaNode getDataChildByName(final QName name) {
+        return findDataChildByName(name).orElse(null);
+    }
+
+    /**
+     * Returns the child node corresponding to the specified name.
+     *
+     * @param name
+     *            QName of child
+     * @return child node of this DataNodeContainer if child with given name is present, empty otherwise
+     * @throws NullPointerException if name is null
      */
-    DataSchemaNode getDataChildByName(QName name);
+    Optional<DataSchemaNode> findDataChildByName(QName name);
 
     /**
      * Returns grouping nodes used ny this container.