ExtensionRegistrar, ExtensionRegistry@API(status=INTERNAL,
since="5.5")
public class MutableExtensionRegistry
extends Object
implements ExtensionRegistry, ExtensionRegistrar
ExtensionRegistry.
A registry has a reference to its parent registry, and all lookups are performed first in the current registry itself and then recursively in its ancestors.
| Modifier and Type | Method | Description |
|---|---|---|
static MutableExtensionRegistry |
createRegistryFrom(MutableExtensionRegistry parentRegistry,
List<Class<? extends Extension>> extensionTypes) |
Factory for creating and populating a new registry from a list of
extension types and a parent registry.
|
static MutableExtensionRegistry |
createRegistryWithDefaultExtensions(JupiterConfiguration configuration) |
Factory for creating and populating a new root registry with the default
extensions.
|
void |
registerExtension(Extension extension,
Object source) |
Register the supplied
Extension, without checking if an extension
of that type already exists. |
<E extends Extension> |
stream(Class<E> extensionType) |
Stream all
Extensions of the specified type that are present
in this registry or one of its ancestors. |
getExtensions, getReversedExtensionspublic static MutableExtensionRegistry createRegistryWithDefaultExtensions(JupiterConfiguration configuration)
If the Constants.EXTENSIONS_AUTODETECTION_ENABLED_PROPERTY_NAME
configuration parameter has been set to true, extensions will be
auto-detected using Java's ServiceLoader mechanism and automatically
registered after the default extensions.
configuration - configuration parameters used to retrieve the extension
auto-detection flag; never nullExtensionRegistry; never nullpublic static MutableExtensionRegistry createRegistryFrom(MutableExtensionRegistry parentRegistry, List<Class<? extends Extension>> extensionTypes)
parentRegistry - the parent registryextensionTypes - the types of extensions to be registered in
the new registryExtensionRegistry; never nullpublic <E extends Extension> Stream<E> stream(Class<E> extensionType)
ExtensionRegistryExtensions of the specified type that are present
in this registry or one of its ancestors.stream in interface ExtensionRegistryextensionType - the type of Extension to streamExtensionRegistry.getReversedExtensions(Class),
ExtensionRegistry.getExtensions(Class)public void registerExtension(Extension extension, Object source)
ExtensionRegistrarExtension, without checking if an extension
of that type already exists.
If an extension is registered declaratively via
@ExtendWith, the
source and the extension should be the same object.
However, if an extension is registered programmatically via
@RegisterExtension,
the source object should be the Field
that is annotated with @RegisterExtension. Similarly, if an
extension is registered programmatically as a lambda expression
or method reference, the source object should be the underlying
Method that implements the extension API.
registerExtension in interface ExtensionRegistrarextension - the extension to register; never nullsource - the source of the extension; never nullCopyright © 2019. All rights reserved.