org.jvnet.jaxbcommons.tree.ClassSearchingNodeVisitor Maven / Gradle / Ivy
package org.jvnet.jaxbcommons.tree;
import java.util.LinkedList;
import java.util.List;
public class ClassSearchingNodeVisitor implements NodeVisitor {
private final Class targetClass;
private final List foundNodes;
public ClassSearchingNodeVisitor(final Class theClass) {
this.targetClass = theClass;
this.foundNodes = new LinkedList();
}
public Object visitNode(Node node) {
if (targetClass.equals(node.getType())) {
foundNodes.add(node);
}
final Node[] children = node.getChildren();
for (int index = 0; index < children.length; index++) {
final Node childNode = children[index];
childNode.visit(this);
}
return foundNodes;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy