Class AnnotationBasedArgumentConverter<A extends java.lang.annotation.Annotation>
- java.lang.Object
-
- org.junit.jupiter.params.converter.AnnotationBasedArgumentConverter<A>
-
- All Implemented Interfaces:
java.util.function.Consumer<A>
,ArgumentConverter
,AnnotationConsumer<A>
- Direct Known Subclasses:
JavaTimeArgumentConverter
@API(status=EXPERIMENTAL, since="5.10") public abstract class AnnotationBasedArgumentConverter<A extends java.lang.annotation.Annotation> extends java.lang.Object implements ArgumentConverter, AnnotationConsumer<A>
AnnotationBasedArgumentConverter
is an abstract base class forArgumentConverter
implementations that also need to consume an annotation in order to perform the conversion.- Since:
- 5.10
- See Also:
ArgumentConverter
,AnnotationConsumer
,SimpleArgumentConverter
-
-
Field Summary
Fields Modifier and Type Field Description private A
annotation
-
Constructor Summary
Constructors Constructor Description AnnotationBasedArgumentConverter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
accept(A annotation)
protected abstract java.lang.Object
convert(java.lang.Object source, java.lang.Class<?> targetType, A annotation)
Convert the suppliedsource
object into the suppliedtargetType
, based on metadata in the provided annotation.java.lang.Object
convert(java.lang.Object source, org.junit.jupiter.api.extension.ParameterContext context)
Convert the suppliedsource
object according to the suppliedcontext
.
-
-
-
Field Detail
-
annotation
private A extends java.lang.annotation.Annotation annotation
-
-
Method Detail
-
accept
public final void accept(A annotation)
- Specified by:
accept
in interfacejava.util.function.Consumer<A extends java.lang.annotation.Annotation>
-
convert
public final java.lang.Object convert(java.lang.Object source, org.junit.jupiter.api.extension.ParameterContext context) throws ArgumentConversionException
Description copied from interface:ArgumentConverter
Convert the suppliedsource
object according to the suppliedcontext
.- Specified by:
convert
in interfaceArgumentConverter
- Parameters:
source
- the source object to convert; may benull
context
- the parameter context where the converted object will be used; nevernull
- Returns:
- the converted object; may be
null
but only if the target type is a reference type - Throws:
ArgumentConversionException
- if an error occurs during the conversion
-
convert
protected abstract java.lang.Object convert(java.lang.Object source, java.lang.Class<?> targetType, A annotation) throws ArgumentConversionException
Convert the suppliedsource
object into the suppliedtargetType
, based on metadata in the provided annotation.- Parameters:
source
- the source object to convert; may benull
targetType
- the target type the source object should be converted into; nevernull
annotation
- the annotation to process; nevernull
- Returns:
- the converted object; may be
null
but only if the target type is a reference type - Throws:
ArgumentConversionException
- in case an error occurs during the conversion
-
-