Set selectProviders()

in src/main/java/org/apache/sling/graphql/schema/aggregator/impl/DefaultSchemaAggregator.java [131:159]


    Set<Partial> selectProviders(Map<PartialInfo, Partial> providers, Set<String> missing, String ... providerNamesOrRegexp) {
        final Set<Partial> result= new LinkedHashSet<>();
        for(String str : providerNamesOrRegexp) {
            final Pattern p = toRegexp(str);
            if(p != null) {
                log.debug("Selecting providers matching {}", p);
                providers.entrySet().stream()
                    .filter(e -> p.matcher(e.getKey().getName()).matches())
                    .sorted(Comparator.comparing(e -> e.getValue().getPartialInfo()))
                    .forEach(e -> addWithRequirements(providers, result, missing, e.getValue(), 0))
                ;
            } else {
                log.debug("Selecting provider with key={}", str);
                Optional<PartialInfo> fromString = PartialInfo.fromRequiresSection(str).stream().findFirst();
                if (fromString.isPresent()) {
                    PartialInfo selected = fromString.get();
                    final Partial psp = providers.get(selected);
                    if (psp == null) {
                        missing.add(str);
                        continue;
                    }
                    addWithRequirements(providers, result, missing, psp, 0);
                } else {
                    missing.add(str);
                }
            }
        }
        return result;
    }