diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/ObjectProvider.java b/spring-beans/src/main/java/org/springframework/beans/factory/ObjectProvider.java index 2768d066c3bc..e1087cc8d411 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/ObjectProvider.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/ObjectProvider.java @@ -149,8 +149,14 @@ default void ifAvailable(Consumer dependencyConsumer) throws BeansException { /** * Return an instance (possibly shared or independent) of the object * managed by this factory. - * @return an instance of the bean, or {@code null} if not available or - * not unique (i.e. multiple candidates found with none marked as primary) + *

An instance is considered as unique when multiple candidates found + * if it meet one of the following conditions: + *

+ * @return an instance of the bean, or {@code null} if not available or not unique * @throws BeansException in case of creation errors * @see #getObject() */ @@ -167,10 +173,10 @@ default void ifAvailable(Consumer dependencyConsumer) throws BeansException { * Return an instance (possibly shared or independent) of the object * managed by this factory. * @param defaultSupplier a callback for supplying a default object - * if no unique candidate is present in the factory + * if no unique (refer to {@link #getIfUnique()} for the definition) + * candidate is present in the factory * @return an instance of the bean, or the supplied default object * if no such bean is available or if it is not unique in the factory - * (i.e. multiple candidates found with none marked as primary) * @throws BeansException in case of creation errors * @since 5.0 * @see #getIfUnique() @@ -182,12 +188,12 @@ default T getIfUnique(Supplier defaultSupplier) throws BeansException { /** * Consume an instance (possibly shared or independent) of the object - * managed by this factory, if unique. + * managed by this factory, if unique (refer to {@link #getIfUnique()} for the definition). * @param dependencyConsumer a callback for processing the target object * if unique (not called otherwise) * @throws BeansException in case of creation errors * @since 5.0 - * @see #getIfAvailable() + * @see #getIfUnique() */ default void ifUnique(Consumer dependencyConsumer) throws BeansException { T dependency = getIfUnique();