public abstract class BeanUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
addToContextIfMissing(String beanName,
Supplier<T> supplier,
org.springframework.context.ApplicationContext applicationContext)
Adds a bean named
beanName to applicationContext as supplied by supplier if it does not yet exist. |
static <T> T |
findBean(Class<T> type,
String name,
org.springframework.context.ApplicationContext applicationContext)
Attempt to find the spring bean corresponding to
type if only one exists (name not used). |
static Field |
findField(Class<?> clazz,
String name,
Class<?> type)
|
public static <T> T findBean(Class<T> type, @Nullable String name, org.springframework.context.ApplicationContext applicationContext)
Attempt to find the spring bean corresponding to type if only one exists (name not used).
If multiple exist for that type, return the one with the corresponding name.
T - type - name - may be nullapplicationContext - public static Field findField(Class<?> clazz, @Nullable String name, Class<?> type)
Attempt to find a field on the supplied class with the
supplied name and type OR just the type if none with this name exists.
Searches all superclasses up to Object.
clazz - name - type - public static <T> T addToContextIfMissing(String beanName, Supplier<T> supplier, org.springframework.context.ApplicationContext applicationContext)
beanName to applicationContext as supplied by supplier if it does not yet exist.T - beanName - supplier - applicationContext - Copyright © 2022. All rights reserved.