Example usage for com.badlogic.gdx.utils Predicate evaluate

List of usage examples for com.badlogic.gdx.utils Predicate evaluate

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils Predicate evaluate.

Prototype

boolean evaluate(T arg0);

Source Link

Usage

From source file:es.eucm.ead.editor.view.widgets.AbstractWidget.java

License:Open Source License

/**
 * Finds an actor that fulfills the given predicate, starting the search in
 * the given root/*from  www  .  j  av a2s  .  c om*/
 * 
 * @return the actor found. Could be {@code null} if no actor matched the
 *         predicate
 */
public static Actor findActor(Group root, Predicate<Actor> predicate) {
    if (predicate.evaluate(root)) {
        return root;
    }

    for (Actor child : root.getChildren()) {
        if (predicate.evaluate(child)) {
            return child;
        } else if (child instanceof Group) {
            Actor actor = findActor((Group) child, predicate);
            if (actor != null) {
                return actor;
            }
        }
    }
    return null;
}