Class SpringExtensions
java.lang.Object
org.springframework.data.gemfire.util.SpringExtensions
- Direct Known Subclasses:
DistributedSystemUtils
Abstract utility class encapsulating functionality common to
Objects
, Class types
and Spring beans.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.beans.factory.config.BeanDefinition
addDependsOn
(org.springframework.beans.factory.config.BeanDefinition beanDefinition, String... beanNames) Adds an array of bean dependencies (byname
) to the givenBeanDefinition
.static boolean
areNotNull
(Object... values) Determines whether all theObject
values in the array are non-null.static String
defaultIfEmpty
(String value, String defaultValue) static String
defaultIfEmpty
(String value, Supplier<String> supplier) static <T> T
defaultIfNull
(T value, Supplier<T> supplier) static <T> T
defaultIfNull
(T value, T defaultValue) static String
dereferenceBean
(String beanName) static boolean
equalsIgnoreNull
(Object obj1, Object obj2) static <T> List<T>
getBeansOfTypeOrdered
(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Class<T> beanType) static <T> List<T>
getBeansOfTypeOrdered
(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Class<T> beanType, boolean includeNonSingletons, boolean allowEagerInit) static Integer
static <T> Stream<T>
getOrderedStreamOfBeansByType
(org.springframework.beans.factory.BeanFactory beanFactory, Class<T> beanType) getPropertyValue
(org.springframework.beans.factory.config.BeanDefinition beanDefinition, String propertyName) static boolean
isMatchingBean
(org.springframework.beans.factory.BeanFactory beanFactory, String beanName, Class<?> beanType) static boolean
nullOrEquals
(Object obj1, Object obj2) static boolean
nullSafeEquals
(Object obj1, Object obj2) static String
nullSafeName
(Class<?> type) static String
nullSafeSimpleName
(Class<?> type) static Class<?>
nullSafeType
(Object target) static Class<?>
nullSafeType
(Object target, Class<?> defaultType) static <T> T
requireObject
(Supplier<T> objectSupplier, String message) static <T> T
requireObject
(T object, String message) static boolean
static boolean
safeDoOperation
(SpringExtensions.VoidReturningThrowableOperation operation, Runnable backupOperation) static <T> T
static <T> T
safeGetValue
(SpringExtensions.ValueReturningThrowableOperation<T> operation, Function<Throwable, T> exceptionHandler) static <T> T
safeGetValue
(SpringExtensions.ValueReturningThrowableOperation<T> operation, Supplier<T> defaultValueSupplier) static <T> T
safeGetValue
(SpringExtensions.ValueReturningThrowableOperation<T> operation, T defaultValue) static void
static void
safeRunOperation
(SpringExtensions.VoidReturningThrowableOperation operation, Function<Throwable, RuntimeException> exceptionConverter) static org.springframework.beans.factory.config.BeanDefinition
setPropertyReference
(org.springframework.beans.factory.config.BeanDefinition beanDefinition, String propertyName, String beanName) static org.springframework.beans.factory.config.BeanDefinition
setPropertyValue
(org.springframework.beans.factory.config.BeanDefinition beanDefinition, String propertyName, Object propertyValue)
-
Constructor Details
-
SpringExtensions
public SpringExtensions()
-
-
Method Details
-
areNotNull
Determines whether all theObject
values in the array are non-null. -
isMatchingBean
-
addDependsOn
@NonNull public static org.springframework.beans.factory.config.BeanDefinition addDependsOn(@NonNull org.springframework.beans.factory.config.BeanDefinition beanDefinition, String... beanNames) Adds an array of bean dependencies (byname
) to the givenBeanDefinition
.- Parameters:
beanDefinition
-BeanDefinition
to add the bean dependencies; must not be null.beanNames
- array ofnames
of beans for which theBeanDefinition
depends on, or will have a dependency.- Returns:
- the given
BeanDefinition
. - See Also:
-
BeanDefinition
-
getBeansOfTypeOrdered
@NonNull public static <T> List<T> getBeansOfTypeOrdered(@NonNull org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, @NonNull Class<T> beanType) - Type Parameters:
T
-type
of the bean.- Parameters:
beanFactory
-Spring container
used to acquire the ordered beans.beanType
-type
of beans to acquire.- Returns:
- a
List
of beans of the giventype
in order. - See Also:
-
getBeansOfTypeOrdered(ConfigurableListableBeanFactory, Class, boolean, boolean)
ConfigurableListableBeanFactory
Class
List
-
getBeansOfTypeOrdered
@NonNull public static <T> List<T> getBeansOfTypeOrdered(@NonNull org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, @NonNull Class<T> beanType, boolean includeNonSingletons, boolean allowEagerInit) - Type Parameters:
T
-type
of the bean.- Parameters:
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 initializeFactoryBeans
.- Returns:
- a
List
of beans of the giventype
in order. - See Also:
-
getOrder
-
getOrderedStreamOfBeansByType
-
getPropertyValue
-
setPropertyReference
-
setPropertyValue
-
defaultIfEmpty
-
defaultIfEmpty
-
defaultIfNull
public static <T> T defaultIfNull(T value, T defaultValue) -
defaultIfNull
-
dereferenceBean
-
equalsIgnoreNull
-
nullOrEquals
-
nullSafeEquals
-
nullSafeName
-
nullSafeSimpleName
-
nullSafeType
-
nullSafeType
-
requireObject
-
requireObject
-
safeDoOperation
-
safeDoOperation
public static boolean safeDoOperation(SpringExtensions.VoidReturningThrowableOperation operation, Runnable backupOperation) -
safeGetValue
-
safeGetValue
public static <T> T safeGetValue(SpringExtensions.ValueReturningThrowableOperation<T> operation, T defaultValue) -
safeGetValue
public static <T> T safeGetValue(SpringExtensions.ValueReturningThrowableOperation<T> operation, Supplier<T> defaultValueSupplier) -
safeGetValue
public static <T> T safeGetValue(SpringExtensions.ValueReturningThrowableOperation<T> operation, Function<Throwable, T> exceptionHandler) -
safeRunOperation
-
safeRunOperation
public static void safeRunOperation(SpringExtensions.VoidReturningThrowableOperation operation, Function<Throwable, RuntimeException> exceptionConverter)
-