Class BeanLookup

java.lang.Object
org.springframework.data.util.BeanLookup

public abstract class BeanLookup extends Object
Simple helper to allow lenient lookup of beans of a given type from a ListableBeanFactory. This is not user facing API but a mere helper for Spring Data configuration code.
Since:
2.1
Author:
Oliver Gierke
  • Method Details

    • lazyIfAvailable

      public static <T> Lazy<T> lazyIfAvailable(Class<T> type, BeanFactory beanFactory)
      Returns a Lazy for the unique bean of the given type from the given BeanFactory (which needs to be a ListableBeanFactory). The lookup will produce a NoUniqueBeanDefinitionException in case multiple beans of the given type are available in the given BeanFactory.
      Parameters:
      type - must not be null.
      beanFactory - the BeanFactory to lookup the bean from.
      Returns:
      a Lazy for the unique bean of the given type or the instance provided by the fallback in case no bean of the given type can be found.