Class ExtensionUtils
- java.lang.Object
-
- org.junit.jupiter.engine.descriptor.ExtensionUtils
-
final class ExtensionUtils extends java.lang.Object
Collection of utilities for working with extensions and the extension registry.- Since:
- 5.1
- See Also:
ExtensionRegistrar
,MutableExtensionRegistry
,ExtendWith
,RegisterExtension
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Comparator<java.lang.reflect.Field>
orderComparator
-
Constructor Summary
Constructors Modifier Constructor Description private
ExtensionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static int
getOrder(java.lang.reflect.Field field)
(package private) static MutableExtensionRegistry
populateNewExtensionRegistryFromExtendWithAnnotation(MutableExtensionRegistry parentRegistry, java.lang.reflect.AnnotatedElement annotatedElement)
Populate a newMutableExtensionRegistry
from extension types declared via@ExtendWith
on the suppliedAnnotatedElement
.(package private) static void
registerExtensionsFromFields(ExtensionRegistrar registrar, java.lang.Class<?> clazz, java.lang.Object instance)
Register extensions in the supplied registry from fields in the supplied class that are annotated with@RegisterExtension
.
-
-
-
Method Detail
-
populateNewExtensionRegistryFromExtendWithAnnotation
static MutableExtensionRegistry populateNewExtensionRegistryFromExtendWithAnnotation(MutableExtensionRegistry parentRegistry, java.lang.reflect.AnnotatedElement annotatedElement)
Populate a newMutableExtensionRegistry
from extension types declared via@ExtendWith
on the suppliedAnnotatedElement
.- Parameters:
parentRegistry
- the parent extension registry to set in the newly created registry; nevernull
annotatedElement
- the annotated element on which to search for declarations of@ExtendWith
; nevernull
- Returns:
- the new extension registry; never
null
- Since:
- 5.0
-
registerExtensionsFromFields
static void registerExtensionsFromFields(ExtensionRegistrar registrar, java.lang.Class<?> clazz, java.lang.Object instance)
Register extensions in the supplied registry from fields in the supplied class that are annotated with@RegisterExtension
.The extensions will be sorted according to
@Order
semantics prior to registration.- Parameters:
registrar
- the registrar with which to register the extensions; nevernull
clazz
- the class or interface in which to find the fields; nevernull
instance
- the instance of the supplied class; may benull
when searching forstatic
fields in the class
-
getOrder
private static int getOrder(java.lang.reflect.Field field)
- Since:
- 5.4
-
-