@API(value=Internal)
public class ExtensionRegistry
extends java.lang.Object
ExtensionRegistry holds all registered extensions (i.e.
instances of Extension) for a given
Node.
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 and Description |
|---|---|
static ExtensionRegistry |
createRegistryFrom(ExtensionRegistry parentRegistry,
java.util.List<java.lang.Class<? extends org.junit.jupiter.api.extension.Extension>> extensionTypes)
Factory for creating and populating a new registry from a list of
extension types and a parent registry.
|
static ExtensionRegistry |
createRegistryWithDefaultExtensions()
Factory for creating and populating a new root registry with the default
extensions.
|
<E extends org.junit.jupiter.api.extension.Extension> |
getExtensions(java.lang.Class<E> extensionType)
Get all
Extensions in this registry or one of its ancestors of
the specified type. |
<E extends org.junit.jupiter.api.extension.Extension> |
getReversedExtensions(java.lang.Class<E> extensionType)
Get all
Extensions in this registry or one of its ancestors of
the specified type, in reverse order. |
void |
registerExtension(org.junit.jupiter.api.extension.Extension extension,
java.lang.Object source)
Register the supplied
Extension in this registry, without checking
if an extension of that type already exists in this registry. |
<E extends org.junit.jupiter.api.extension.Extension> |
stream(java.lang.Class<E> extensionType)
Generate a stream for iterating over all registered extensions of the
specified type.
|
public static ExtensionRegistry createRegistryWithDefaultExtensions()
ExtensionRegistrypublic static ExtensionRegistry createRegistryFrom(ExtensionRegistry parentRegistry, java.util.List<java.lang.Class<? extends org.junit.jupiter.api.extension.Extension>> extensionTypes)
parentRegistry - the parent registryextensionTypes - the types of extensions to be registered in
the new registryExtensionRegistrypublic <E extends org.junit.jupiter.api.extension.Extension> java.util.List<E> getExtensions(java.lang.Class<E> extensionType)
Extensions in this registry or one of its ancestors of
the specified type.extensionType - the type of Extension to getgetReversedExtensions(Class),
stream(Class)public <E extends org.junit.jupiter.api.extension.Extension> java.util.List<E> getReversedExtensions(java.lang.Class<E> extensionType)
Extensions in this registry or one of its ancestors of
the specified type, in reverse order.extensionType - the type of Extension to getgetExtensions(Class),
stream(Class)public <E extends org.junit.jupiter.api.extension.Extension> java.util.stream.Stream<E> stream(java.lang.Class<E> extensionType)
extensionType - the type of Extension to streamgetExtensions(Class),
getReversedExtensions(Class)public void registerExtension(org.junit.jupiter.api.extension.Extension extension,
java.lang.Object source)
Extension in this registry, without checking
if an extension of that type already exists in this registry.
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 — for example, as a lambda
expression or method reference — the source object should be the
underlying Method that implements the extension
API, or similar.
extension - the extension to registersource - the source of the extension