Class ConfigurationBasedInstanceCreator
- java.lang.Object
-
- de.rwth.swc.coffee4j.junit.engine.annotation.util.configuration.ConfigurationBasedInstanceCreator
-
public final class ConfigurationBasedInstanceCreator extends Object
Utility class for creating instances based onConfigurationProvider
registered viaConfigurationSource
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
create(Class<T> configurableClass, Method method)
Creates a new instance of a class, possibly with a suppliedConfigurationProvider
.
-
-
-
Method Detail
-
create
public static <T> T create(Class<T> configurableClass, Method method)
Creates a new instance of a class, possibly with a suppliedConfigurationProvider
.Searches for a
ConfigurationSource
of with the correctConfigurationSource.configurable()
on themethod
. If such a source is found, the instance is created using the supplied configuration, otherwise a no-args constructor is used. Consequently, theconfigurableClass
should always have a no-args constructor.- Type Parameters:
T
- the type of the instance created by the method- Parameters:
configurableClass
- the class for which an instance should be created, possibly with a configuration supplied by aConfigurationProvider
on themethod
. Must not benull
method
- the method possibly annotated withConfigurationSource
. Must not benull
- Returns:
- the instance created with a configuration if one was provided. Never
null
-
-