Package org.robolectric.plugins
Class ConfigConfigurer
- java.lang.Object
-
- org.robolectric.plugins.ConfigConfigurer
-
- All Implemented Interfaces:
Configurer<Config>
@AutoService(Configurer.class) public class ConfigConfigurer extends Object implements Configurer<Config>
Provides configuration to Robolectric for its @Config
annotation.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConfigConfigurer(PackagePropertiesLoader packagePropertiesLoader)
ConfigConfigurer(PackagePropertiesLoader packagePropertiesLoader, GlobalConfigProvider defaultConfigProvider)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Config
defaultConfig()
Returns the default configuration for tests that do not specify a configuration of this type.static Config
get(ConfigurationStrategy.Configuration testConfig)
Class<Config>
getConfigClass()
Retrieve the class type for this ConfigurerConfig
getConfigFor(Class<?> testClass)
Returns the configuration for the given class.Config
getConfigFor(Method method)
Returns the configuration for the given method.Config
getConfigFor(String packageName)
Returns the configuration for a given package.Config
merge(Config parentConfig, Config childConfig)
Merges two configurations.
-
-
-
Constructor Detail
-
ConfigConfigurer
protected ConfigConfigurer(PackagePropertiesLoader packagePropertiesLoader)
-
ConfigConfigurer
public ConfigConfigurer(PackagePropertiesLoader packagePropertiesLoader, GlobalConfigProvider defaultConfigProvider)
-
-
Method Detail
-
get
public static Config get(ConfigurationStrategy.Configuration testConfig)
-
getConfigClass
public Class<Config> getConfigClass()
Description copied from interface:Configurer
Retrieve the class type for this Configurer- Specified by:
getConfigClass
in interfaceConfigurer<Config>
-
defaultConfig
@Nonnull public Config defaultConfig()
Description copied from interface:Configurer
Returns the default configuration for tests that do not specify a configuration of this type.- Specified by:
defaultConfig
in interfaceConfigurer<Config>
-
getConfigFor
public Config getConfigFor(@Nonnull String packageName)
Description copied from interface:Configurer
Returns the configuration for a given package.This method will be called once for package in the hierarchy leading to the test class being configured. For example, for
com.example.FooTest
, this method will be called three times with"com.example"
,"@com"
, and""
(representing the top level package).- Specified by:
getConfigFor
in interfaceConfigurer<Config>
- Parameters:
packageName
- the name of the package, or the empty string representing the top level unnamed package- Returns:
- a configuration object, or null if the given properties has no relevant data for this configuration
-
getConfigFor
public Config getConfigFor(@Nonnull Class<?> testClass)
Description copied from interface:Configurer
Returns the configuration for the given class.This method will be called for each class in the test's class inheritance hierarchy.
- Specified by:
getConfigFor
in interfaceConfigurer<Config>
- Returns:
- a configuration object, or null if the given class has no relevant data for this configuration
-
getConfigFor
public Config getConfigFor(@Nonnull Method method)
Description copied from interface:Configurer
Returns the configuration for the given method.- Specified by:
getConfigFor
in interfaceConfigurer<Config>
- Returns:
- a configuration object, or null if the given method has no relevant data for this configuration
-
merge
@Nonnull public Config merge(@Nonnull Config parentConfig, @Nonnull Config childConfig)
Description copied from interface:Configurer
Merges two configurations. This method will called wheneverConfigurer.getConfigFor(java.lang.String)
returns a non-null configuration object.- Specified by:
merge
in interfaceConfigurer<Config>
- Parameters:
parentConfig
- a less specific configuration objectchildConfig
- a more specific configuration object- Returns:
- the new configuration with merged parent and child data.
-
-