BeanFactoryAnnotationUtils currently only provides methods to extract beans by raw type. Overloaded methods that work with ResolvableType (for instance) would be helpful - they could be implemented using the ObjectProvider abstraction.

Comment From: jhoeller

What specifically are you trying to look up there? The rather niche BeanFactoryAnnotationUtils is really only a helper for simple qualifier matching...

Comment From: dsyer

I agree it's a corner case. I needed to implement it for completeness more than anything - I haven't seen an example of this in the wild, but it came up in tests in Spring Init. My implementation:

    public static <T> T available(ListableBeanFactory beans,
            ResolvableType type) {
        return generic(beans.getBeanProvider(type).getIfAvailable());
    }

    public static <T> T available(ListableBeanFactory beans,
            ResolvableType type, String qualifier) {
        for (String name : beans.getBeanNamesForType(type)) {
            if (BeanFactoryAnnotationUtils.isQualifierMatch(qualifier::equals, name, beans)) {
                return generic(beans.getBean(name));
            }
        }
        throw new NoSuchBeanDefinitionException("Could not locate bean of type " + type + " qualified as '" + qualifier + "'");
    }

Actually, it did crop up in the wild, but only in ways that were accidentally unambiguous with the raw type.

Comment From: snicoll

Given what BeanFactoryAnnotationUtils currently does, I don't really think it makes sense to introduce a method for checking against a generic type since it won't be used anyway.