Class Configurations
java.lang.Object
org.springframework.boot.context.annotation.Configurations
- Direct Known Subclasses:
UserConfigurations
A set of
@Configuration
classes that can be registered in
ApplicationContext
. Classes can be returned from one or more
Configurations
instances by using getClasses(Configurations[])
. The
resulting array follows the ordering rules usually applied by the
ApplicationContext
and/or custom ImportSelector
implementations.
This class is primarily intended for use with tests that need to specify configuration
classes but can't use SpringRunner
.
Implementations of this class should be annotated with @Order
or
implement Ordered
.
- Since:
- 2.0.0
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
Configurations
(Collection<Class<?>> classes) Create a newConfigurations
instance.protected
Configurations
(UnaryOperator<Collection<Class<?>>> sorter, Collection<Class<?>> classes, Function<Class<?>, String> beanNameGenerator) Create a newConfigurations
instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic List<Configurations>
collate
(Collection<Configurations> configurations) Collate the given configuration by sorting and merging them.getBeanName
(Class<?> beanClass) Return the bean name that should be used for the given configuration class ornull
to use the default name.static Class<?>[]
getClasses
(Collection<Configurations> configurations) Return the classes from all the specified configurations in the order that they would be registered.static Class<?>[]
getClasses
(Configurations... configurations) Return the classes from all the specified configurations in the order that they would be registered.protected abstract Configurations
Merge configurations.protected Configurations
merge
(Configurations other) Merge configurations from another source of the same type.protected Collection<Class<?>>
sort
(Collection<Class<?>> classes) Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
Configurations
Create a newConfigurations
instance.- Parameters:
classes
- the configuration classes
-
Configurations
protected Configurations(UnaryOperator<Collection<Class<?>>> sorter, Collection<Class<?>> classes, Function<Class<?>, String> beanNameGenerator) Create a newConfigurations
instance.- Parameters:
sorter
- aUnaryOperator
used to sort the configurationsclasses
- the configuration classesbeanNameGenerator
- an optional function used to generate the bean name- Since:
- 3.4.0
-
-
Method Details
-
getClasses
-
sort
@Deprecated(since="3.4.0", forRemoval=true) protected Collection<Class<?>> sort(Collection<Class<?>> classes) Deprecated, for removal: This API element is subject to removal in a future version.since 3.4.0 for removal in 3.6.0 in favor ofConfigurations(UnaryOperator, Collection, Function)
Sort configuration classes into the order that they should be applied.- Parameters:
classes
- the classes to sort- Returns:
- a sorted set of classes
-
merge
Merge configurations from another source of the same type.- Parameters:
other
- the otherConfigurations
(must be of the same type as this instance)- Returns:
- a new configurations instance (must be of the same type as this instance)
-
merge
Merge configurations.- Parameters:
mergedClasses
- the merged classes- Returns:
- a new configurations instance (must be of the same type as this instance)
-
getBeanName
Return the bean name that should be used for the given configuration class ornull
to use the default name.- Parameters:
beanClass
- the bean class- Returns:
- the bean name
- Since:
- 3.4.0
-
getClasses
Return the classes from all the specified configurations in the order that they would be registered.- Parameters:
configurations
- the source configuration- Returns:
- configuration classes in registration order
-
getClasses
Return the classes from all the specified configurations in the order that they would be registered.- Parameters:
configurations
- the source configuration- Returns:
- configuration classes in registration order
-
collate
Collate the given configuration by sorting and merging them.- Parameters:
configurations
- the source configuration- Returns:
- the collated configurations
- Since:
- 3.4.0
-
Configurations(UnaryOperator, Collection, Function)