public abstract class SpringUtils extends Object
Objects, Class types
and Spring beans.Class,
Object,
Function,
Stream,
BeanFactory,
FactoryBean,
BeanDefinition,
RuntimeBeanReference,
Ordered,
AnnotationAwareOrderComparator,
Order| Modifier and Type | Class and Description |
|---|---|
static interface |
SpringUtils.OrderedBeanWrapper<T> |
static interface |
SpringUtils.ValueReturningThrowableOperation<T> |
static interface |
SpringUtils.VoidReturningExceptionThrowingOperation
Deprecated.
|
static interface |
SpringUtils.VoidReturningThrowableOperation |
| Constructor and Description |
|---|
SpringUtils() |
public static boolean isMatchingBean(@NonNull BeanFactory beanFactory, String beanName, Class<?> beanType)
beanFactory - Spring container in which to resolve the bean;
must not be null.beanName - name of the bean.beanType - type of the bean.Spring container contains a bean
matching by both name and type.BeanFactory,
Class,
String@NonNull public static BeanDefinition addDependsOn(@NonNull BeanDefinition beanDefinition, @Nullable String... beanNames)
BeanDefinition.beanDefinition - BeanDefinition to add the bean dependencies to; must not be null.beanNames - String array containing names of beans for which the BeanDefinition
depends on (or has a dependency).BeanDefinition.BeanDefinition@NonNull public static <T> List<T> getBeansOfTypeOrdered(@NonNull ConfigurableListableBeanFactory beanFactory, @NonNull Class<T> beanType)
T - type of the bean.beanFactory - Spring container used to acquire the ordered beans.beanType - type of beans to acquire.List of beans of the given type in order.getBeansOfTypeOrdered(ConfigurableListableBeanFactory, Class, boolean, boolean),
ConfigurableListableBeanFactory,
Class,
List@NonNull public static <T> List<T> getBeansOfTypeOrdered(@NonNull ConfigurableListableBeanFactory beanFactory, @NonNull Class<T> beanType, boolean includeNonSingletons, boolean allowEagerInit)
T - type of the bean.beanFactory - Spring container used to acquire the ordered beans.beanType - type of beans to acquire.includeNonSingletons - boolean indicating whether to include non-Singleton beans from the Spring container.allowEagerInit - boolean indicating whether to eagerly initialize FactoryBeans.List of beans of the given type in order.ConfigurableListableBeanFactory,
Class,
Listpublic static <T> Stream<T> getOrderedStreamOfBeansByType(@NonNull BeanFactory beanFactory, @NonNull Class<T> beanType)
T - type of the beans.beanFactory - BeanFactory from which to acquire the beans.beanType - type of the beans.Stream of beans from the BeanFactory of the given type.BeanFactory,
Stream,
Classpublic static Optional<Object> getPropertyValue(BeanDefinition beanDefinition, String propertyName)
public static BeanDefinition setPropertyReference(BeanDefinition beanDefinition, String propertyName, String beanName)
public static BeanDefinition setPropertyValue(BeanDefinition beanDefinition, String propertyName, Object propertyValue)
public static <T> T defaultIfNull(T value,
T defaultValue)
public static <T> T defaultIfNull(T value,
Supplier<T> supplier)
public static <T> T requireObject(@NonNull Supplier<T> objectSupplier, String message)
public static boolean safeDoOperation(SpringUtils.VoidReturningThrowableOperation operation)
public static boolean safeDoOperation(SpringUtils.VoidReturningThrowableOperation operation, Runnable backupOperation)
public static <T> T safeGetValue(SpringUtils.ValueReturningThrowableOperation<T> operation)
public static <T> T safeGetValue(SpringUtils.ValueReturningThrowableOperation<T> operation, T defaultValue)
public static <T> T safeGetValue(SpringUtils.ValueReturningThrowableOperation<T> operation, Supplier<T> defaultValueSupplier)
public static <T> T safeGetValue(SpringUtils.ValueReturningThrowableOperation<T> operation, Function<Throwable,T> exceptionHandler)
public static void safeRunOperation(SpringUtils.VoidReturningThrowableOperation operation)
public static void safeRunOperation(SpringUtils.VoidReturningThrowableOperation operation, Function<Throwable,RuntimeException> exceptionConverter)
Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.