Eliminate HelperMethods
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / DataNodeContainer.java
index 8d44da96c25bb8be5035d8ad54901e81c9c307c4..27d3f18fed3552a41f87cc3a995288ecdcf2194a 100644 (file)
@@ -147,7 +147,7 @@ public interface DataNodeContainer {
     default Optional<DataSchemaNode> findDataTreeChild(final QName name) {
         // First we try to find a direct child and check if it is a data node (as per RFC7950)
         final Optional<DataSchemaNode> optDataChild = findDataChildByName(name);
-        if (HelperMethods.isDataNode(optDataChild)) {
+        if (isDataNode(optDataChild)) {
             return optDataChild;
         }
 
@@ -207,4 +207,14 @@ public interface DataNodeContainer {
             parent = (DataNodeContainer) child;
         } while (true);
     }
+
+    private static boolean isDataNode(final Optional<DataSchemaNode> optNode) {
+        return optNode.isPresent() && isDataNode(optNode.orElseThrow());
+    }
+
+    private static boolean isDataNode(final DataSchemaNode node) {
+        return node instanceof ContainerSchemaNode || node instanceof LeafSchemaNode
+                || node instanceof LeafListSchemaNode || node instanceof ListSchemaNode
+                || node instanceof AnydataSchemaNode || node instanceof AnyxmlSchemaNode;
+    }
 }