class TransformerFactory {

    public Transformer get(Configuration configuration) {
        List<Transformer> electedTransformers = context
                .getBeansOfType(Transformer.class)
                .values()
                .stream() //
                .filter(transformer -> transformer.accept(configuration)) //
                .collect(Collectors.toList());
        if (electedTransformers.isEmpty()) {
            throw new IllegalStateException("No transformers eligible for configuration.");
        }
        if (electedTransformers.size() > 1) {
            throw new IllegalStateException("Too many transformers eligible for configuration (got "
                    + electedTransformers.size() + ": " + Arrays.toString(electedTransformers.toArray()) + ")");
        }
        return electedTransformers.get(0);
    }

    private  TransformerFactory();

}