Class PluginLoader
java.lang.Object
org.mockito.internal.configuration.plugins.PluginLoader
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PluginInitializer
private final DefaultMockitoPlugins
-
Constructor Summary
ConstructorsConstructorDescriptionPluginLoader
(DefaultMockitoPlugins plugins, PluginInitializer initializer) PluginLoader
(PluginSwitch pluginSwitch) PluginLoader
(PluginSwitch pluginSwitch, String... alias) Adds an alias for a class name to this plugin loader. -
Method Summary
Modifier and TypeMethodDescription(package private) <ReturnT,
PreferredT extends ReturnT, AlternateType extends ReturnT>
ReturnTloadPlugin
(Class<PreferredT> preferredPluginType, Class<AlternateType> alternatePluginType) Scans the classpath for givenpreferredPluginType
.(package private) <T> T
loadPlugin
(Class<T> pluginType) Scans the classpath for given pluginType.(package private) <T> List
<T> loadPlugins
(Class<T> pluginType) Scans the classpath for givenpluginType
and returns a list of its instances.
-
Field Details
-
plugins
-
initializer
-
-
Constructor Details
-
PluginLoader
PluginLoader(DefaultMockitoPlugins plugins, PluginInitializer initializer) -
PluginLoader
PluginLoader(PluginSwitch pluginSwitch) -
PluginLoader
PluginLoader(PluginSwitch pluginSwitch, String... alias) Adds an alias for a class name to this plugin loader. Instead of the fully qualified type name, the alias can be used as a convenience name for a known plugin. This avoids exposing API that is explicitly marked as internal through the package name. Without such aliases, we would need to make internal packages part of the API, not by code but by configuration file.
-
-
Method Details
-
loadPlugin
Scans the classpath for given pluginType. If not found, default class is used. -
loadPlugin
<ReturnT,PreferredT extends ReturnT, ReturnT loadPluginAlternateType extends ReturnT> (Class<PreferredT> preferredPluginType, Class<AlternateType> alternatePluginType) Scans the classpath for givenpreferredPluginType
. If not found scan foralternatePluginType
. If neither a preferred or alternate plugin is found, default to default class ofpreferredPluginType
.- Returns:
- An object of either
preferredPluginType
oralternatePluginType
, cast to the lowest common denominator in the chain of inheritance
-
loadPlugins
Scans the classpath for givenpluginType
and returns a list of its instances.- Returns:
- An list of
pluginType
or an empty list if none was found.
-