WebComponentExporterUtils { @SuppressWarnings({ "unchecked", "rawtypes" }) public static Set<WebComponentExporterFactory> getFactories( Set<Class<?>> classes) { Set<WebComponentExporterFactory> factories = new HashSet<>(); classes.stream().filter(WebComponentExporter.class::isAssignableFrom) .filter(WebComponentExporterUtils::isEligible) .map(clazz -> new DefaultWebComponentExporterFactory(clazz)) .forEach(factories::add); classes.stream() .filter(WebComponentExporterFactory.class::isAssignableFrom) .filter(clazz -> !Modifier.isAbstract(clazz.getModifiers())) .filter(clazz -> !clazz .equals(DefaultWebComponentExporterFactory.class)) .map(ReflectTools::createInstance) .map(WebComponentExporterFactory.class::cast) .forEach(factories::add); return factories; } private  WebComponentExporterUtils(); @SuppressWarnings({ "unchecked", "rawtypes" }) static Set<WebComponentExporterFactory> getFactories(
            Set<Class<?>> classes);  }
@Test public void getFactories_notEligibleExportersAreFiltered_factoriesAreReturned() { Set<WebComponentExporterFactory> factories = WebComponentExporterUtils .getFactories(new HashSet<>(Arrays.asList(GoodExporter.class, AbstractExporter.class, PackageLocalExporter.class, NoPublicCtorExporter.class, ExporterFactory.class))); Assert.assertEquals(2, factories.size()); Iterator<WebComponentExporterFactory> iterator = factories.iterator(); WebComponentExporterFactory factory = iterator.next(); WebComponentExporterFactory another = iterator.next(); if (factory instanceof ExporterFactory) { assertFactories(factory, another); } else { assertFactories(another, factory); } }