|
46 | 46 | * Alternatively, you may implement the specific methods that your callers expect,
|
47 | 47 | * for example, just {@link #getObject()} or {@link #getIfAvailable()}.
|
48 | 48 | *
|
| 49 | + * <p>Note that {@link #getObject()} never returns {@code null} - it will throw a |
| 50 | + * {@link NoSuchBeanDefinitionException} instead -, whereas {@link #getIfAvailable()} |
| 51 | + * will return {@code null} if no matching bean is present at all. However, both |
| 52 | + * methods will throw a {@link NoUniqueBeanDefinitionException} if more than one |
| 53 | + * matching bean is found without a clear unique winner (see below). Last but not |
| 54 | + * least, {@link #getIfUnique()} will return {@code null} both when no matching bean |
| 55 | + * is found and when more than one matching bean is found without a unique winner. |
| 56 | + * |
| 57 | + * <p>Uniqueness is generally up to the container's candidate resolution algorithm |
| 58 | + * but always honors the "primary" flag (with only one of the candidate beans marked |
| 59 | + * as primary) and the "fallback" flag (with only one of the candidate beans not |
| 60 | + * marked as fallback). The default-candidate flag is consistently taken into |
| 61 | + * account as well, even for non-annotation-based injection points, with a single |
| 62 | + * default candidate winning in case of no clear primary/fallback indication. |
| 63 | + * |
49 | 64 | * @author Juergen Hoeller
|
50 | 65 | * @since 4.3
|
51 | 66 | * @param <T> the object type
|
@@ -188,7 +203,7 @@ default T getIfUnique(Supplier<T> defaultSupplier) throws BeansException {
|
188 | 203 | * if unique (not called otherwise)
|
189 | 204 | * @throws BeansException in case of creation errors
|
190 | 205 | * @since 5.0
|
191 |
| - * @see #getIfAvailable() |
| 206 | + * @see #getIfUnique() |
192 | 207 | */
|
193 | 208 | default void ifUnique(Consumer<T> dependencyConsumer) throws BeansException {
|
194 | 209 | T dependency = getIfUnique();
|
|
0 commit comments