Class PluginLoader

java.lang.Object
org.mockito.internal.configuration.plugins.PluginLoader

class PluginLoader extends Object
  • Field Details

  • 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

      <T> T loadPlugin(Class<T> pluginType)
      Scans the classpath for given pluginType. If not found, default class is used.
    • loadPlugin

      <ReturnT, PreferredT extends ReturnT, AlternateType extends ReturnT> ReturnT loadPlugin(Class<PreferredT> preferredPluginType, Class<AlternateType> alternatePluginType)
      Scans the classpath for given preferredPluginType. If not found scan for alternatePluginType. If neither a preferred or alternate plugin is found, default to default class of preferredPluginType.
      Returns:
      An object of either preferredPluginType or alternatePluginType, cast to the lowest common denominator in the chain of inheritance
    • loadPlugins

      <T> List<T> loadPlugins(Class<T> pluginType)
      Scans the classpath for given pluginType and returns a list of its instances.
      Returns:
      An list of pluginType or an empty list if none was found.