Module org.junit.jupiter.params
Class AnnotationBasedArgumentConverter<A extends Annotation>
java.lang.Object
org.junit.jupiter.params.converter.AnnotationBasedArgumentConverter<A>
- All Implemented Interfaces:
Consumer<A>
,ArgumentConverter
,AnnotationConsumer<A>
@API(status=EXPERIMENTAL,
since="5.10")
public abstract class AnnotationBasedArgumentConverter<A extends Annotation>
extends Object
implements ArgumentConverter, AnnotationConsumer<A>
AnnotationBasedArgumentConverter
is an abstract base class for
ArgumentConverter
implementations that also need to consume an
annotation in order to perform the conversion.- Since:
- 5.10
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
protected abstract Object
Convert the suppliedsource
object into the suppliedtargetType
, based on metadata in the provided annotation.final Object
convert
(Object source, ParameterContext context) Convert the suppliedsource
object according to the suppliedcontext
.
-
Constructor Details
-
AnnotationBasedArgumentConverter
public AnnotationBasedArgumentConverter()
-
-
Method Details
-
accept
- Specified by:
accept
in interfaceConsumer<A extends Annotation>
-
convert
public final Object convert(Object source, 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 Object convert(Object source, 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
-