Search in sources :

Example 46 with FilterBuilder

use of org.reflections.util.FilterBuilder in project sldeditor by robward-scisys.

the class RegisterClasses method registerTextBackground.

/**
 * Register text background converters.
 *
 * @param classLoadersList the class loaders list
 * @param data the data
 */
private static void registerTextBackground(List<ClassLoader> classLoadersList, ConversionData data) {
    logger.info("Text backgrounds supported:");
    Reflections reflections = new Reflections(new ConfigurationBuilder().setScanners(new SubTypesScanner(false), new ResourcesScanner()).setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0]))).filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("com.sldeditor.importdata.esri.textbackground"))));
    Set<Class<? extends Object>> allClasses = reflections.getSubTypesOf(Object.class);
    for (Class<? extends Object> claszz : allClasses) {
        try {
            if (validClass(claszz, EsriTextBackgroundInterface.class)) {
                EsriTextBackgroundInterface textBackgroundObj = (EsriTextBackgroundInterface) claszz.newInstance();
                logger.info(textBackgroundObj.getBackgroundClass().getName());
                data.addTextBackground(textBackgroundObj);
            }
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
Also used : ConfigurationBuilder(org.reflections.util.ConfigurationBuilder) SubTypesScanner(org.reflections.scanners.SubTypesScanner) FilterBuilder(org.reflections.util.FilterBuilder) ResourcesScanner(org.reflections.scanners.ResourcesScanner) EsriTextBackgroundInterface(com.sldeditor.importdata.esri.textbackground.EsriTextBackgroundInterface) Reflections(org.reflections.Reflections)

Aggregations

FilterBuilder (org.reflections.util.FilterBuilder)46 ConfigurationBuilder (org.reflections.util.ConfigurationBuilder)23 Reflections (org.reflections.Reflections)19 Test (org.junit.Test)17 SubTypesScanner (org.reflections.scanners.SubTypesScanner)9 ResourcesScanner (org.reflections.scanners.ResourcesScanner)8 Test (org.junit.jupiter.api.Test)7 ArrayList (java.util.ArrayList)6 URL (java.net.URL)4 lombok.val (lombok.val)4 Field (java.lang.reflect.Field)2 Collection (java.util.Collection)2 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2 Set (java.util.Set)2 BeforeClass (org.junit.BeforeClass)2 MethodAnnotationsScanner (org.reflections.scanners.MethodAnnotationsScanner)2 TypeAnnotationsScanner (org.reflections.scanners.TypeAnnotationsScanner)2 ClasspathHelper (org.reflections.util.ClasspathHelper)2 Stopwatch (com.google.common.base.Stopwatch)1