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=MAINTAINED, since="5.13.3") public abstract class AnnotationBasedArgumentConverter<A extends java.lang.annotation.Annotation> extends java.lang.Object implements ArgumentConverter, AnnotationConsumer<A>AnnotationBasedArgumentConverteris an abstract base class forArgumentConverterimplementations 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 Aannotation
-
Constructor Summary
Constructors Constructor Description AnnotationBasedArgumentConverter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaccept(A annotation)protected abstract java.lang.Objectconvert(java.lang.Object source, java.lang.Class<?> targetType, A annotation)Convert the suppliedsourceobject into the suppliedtargetType, based on metadata in the provided annotation.java.lang.Objectconvert(java.lang.Object source, org.junit.jupiter.api.extension.ParameterContext context)Convert the suppliedsourceobject according to the suppliedcontext.java.lang.Objectconvert(java.lang.Object source, FieldContext context)Convert the suppliedsourceobject 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:
acceptin 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 ArgumentConversionExceptionDescription copied from interface:ArgumentConverterConvert the suppliedsourceobject according to the suppliedcontext.- Specified by:
convertin interfaceArgumentConverter- Parameters:
source- the source object to convert; may benullcontext- the parameter context where the converted object will be supplied; nevernull- Returns:
- the converted object; may be
nullbut only if the target type is a reference type - Throws:
ArgumentConversionException- if an error occurs during the conversion
-
convert
public final java.lang.Object convert(java.lang.Object source, FieldContext context) throws ArgumentConversionExceptionDescription copied from interface:ArgumentConverterConvert the suppliedsourceobject according to the suppliedcontext.- Specified by:
convertin interfaceArgumentConverter- Parameters:
source- the source object to convert; may benullcontext- the field context where the converted object will be injected; nevernull- Returns:
- the converted object; may be
nullbut 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 ArgumentConversionExceptionConvert the suppliedsourceobject into the suppliedtargetType, based on metadata in the provided annotation.- Parameters:
source- the source object to convert; may benulltargetType- the target type the source object should be converted into; nevernullannotation- the annotation to process; nevernull- Returns:
- the converted object; may be
nullbut only if the target type is a reference type - Throws:
ArgumentConversionException- in case an error occurs during the conversion
-
-