class PolicyEngineConfigurator {

    public static PolicyEngine configure(final Collection<String> rulesetRefs) throws IllegalArgumentException {
        if (rulesetRefs == null || rulesetRefs.isEmpty()) {
            throw new IllegalArgumentException("Configuration Error: No rule set reference given");
        }

        final Map<String, Set<Rule>> executorToRuleMapping = rulesetRefs.stream()
                .map(PolicyEngineConfigurator::createRuleset)
                .map(Ruleset::getRules)
                .flatMap(Collection::stream)
                .map(PolicyEngineConfigurator::mapRuleToExecutor)
                .collect(Collectors.groupingBy(RuleToExecutor::getExecutorClass,
                        Collectors.mapping(RuleToExecutor::getRule, Collectors.toSet())));

        PolicyEngine resultEngine = new PolicyEngine(createExecutors(executorToRuleMapping));

        return resultEngine;
    }

}