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

org.jmeterplugins.repository.util.ComponentFinder Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
package org.jmeterplugins.repository.util;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.awt.*;

public class ComponentFinder {
    private static final Logger log = LoggerFactory.getLogger(ComponentFinder.class);

    private final Class search;

    public ComponentFinder(Class cls) {
        search = cls;
    }

    public T findComponentIn(Container container) {
        log.debug("Searching in " + container);
        for (Component a : container.getComponents()) {
            if (search.isAssignableFrom(a.getClass())) {
                log.debug("Found " + a);
                return (T) a;
            }

            if (a instanceof Container) {
                T res = findComponentIn((Container) a);
                if (res != null) {
                    return res;
                }
            }
        }

        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy