Introduce DataNodeContainer.findDataChildByName()
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / DataNodeContainer.java
index 8b15c979a276d1b8819b342c4152abb17a5da23d..308697a7cffd28aadf4f7070a94348d0db6e8e23 100644 (file)
@@ -8,8 +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;
 
 /**
@@ -41,24 +42,33 @@ public interface DataNodeContainer {
     Set<GroupingDefinition> getGroupings();
 
     /**
+     * Returns the child node corresponding to the specified name.
+     *
      * @param name
-     *            QName of seeked child
-     * @return child node of this DataNodeContainer if child with given name is
-     *         present, null otherwise
+     *            QName of child
+     * @return child node of this DataNodeContainer if child with given name is present, null otherwise
+     *
+     * @deprecated Use {@link #findDataChildByName(QName)} instead.
      */
-    DataSchemaNode getDataChildByName(QName name);
+    @Deprecated
+    @Nullable default DataSchemaNode getDataChildByName(final QName name) {
+        return findDataChildByName(name).orElse(null);
+    }
 
     /**
+     * Returns the child node corresponding to the specified name.
+     *
      * @param name
-     *            name of seeked child as String
-     * @return child node of this DataNodeContainer if child with given name is
-     *         present, null otherwise
+     *            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(String name);
+    Optional<DataSchemaNode> findDataChildByName(QName name);
 
     /**
+     * Returns grouping nodes used ny this container.
+     *
      * @return Set of all uses nodes defined within this DataNodeContainer
      */
     Set<UsesNode> getUses();
-
 }