
com.nhl.link.move.runtime.json.query.RecursiveDescent Maven / Gradle / Ivy
package com.nhl.link.move.runtime.json.query;
import com.fasterxml.jackson.databind.JsonNode;
import java.util.ArrayList;
import java.util.List;
class RecursiveDescent extends BaseQuery {
private JsonQuery clientQuery;
public RecursiveDescent(JsonQuery clientQuery) {
this.clientQuery = clientQuery;
}
@Override
public List doExecute(JsonNode rootNode, JsonNodeWrapper currentNode) {
List nodes = new ArrayList<>();
traverseNodes(rootNode, currentNode, nodes);
return nodes;
}
public void traverseNodes(JsonNode rootNode, JsonNodeWrapper currentNode, List accumulator) {
if (currentNode != null) {
List nodes = clientQuery.execute(rootNode, currentNode);
for (JsonNodeWrapper node : nodes) {
if (node != null) {
accumulator.add(node);
}
}
for (JsonNode childNode : currentNode.getNode()) {
traverseNodes(rootNode, Utils.createWrapperNode(currentNode, childNode), accumulator);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy