All Downloads are FREE. Search and download functionalities are using the official Maven repository.

AnnotatedTree.Processor.NodeDrawableCollector Maven / Gradle / Ivy

package AnnotatedTree.Processor;

import AnnotatedTree.ParseNodeDrawable;
import AnnotatedTree.Processor.Condition.NodeDrawableCondition;

import java.util.ArrayList;

public class NodeDrawableCollector {
    private NodeDrawableCondition condition;
    private ParseNodeDrawable rootNode;

    public NodeDrawableCollector(ParseNodeDrawable rootNode, NodeDrawableCondition condition){
        this.rootNode = rootNode;
        this.condition = condition;
    }

    private void collectNodes(ParseNodeDrawable parseNode, ArrayList collected){
        if (condition == null || condition.satisfies(parseNode)){
            collected.add(parseNode);
        }
        for (int i = 0; i < parseNode.numberOfChildren(); i++){
            collectNodes((ParseNodeDrawable)parseNode.getChild(i), collected);
        }
    }

    public ArrayList collect(){
        ArrayList result = new ArrayList();
        collectNodes(rootNode, result);
        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy