Module org.junit.jupiter.params
Class TypedArgumentConverter<S,T>
java.lang.Object
org.junit.jupiter.params.converter.TypedArgumentConverter<S,T>
- Type Parameters:
S
- the type of the source argument to convertT
- the type of the target object to create from the source
- All Implemented Interfaces:
ArgumentConverter
@API(status=STABLE,
since="5.10")
public abstract class TypedArgumentConverter<S,T>
extends Object
implements ArgumentConverter
TypedArgumentConverter
is an abstract base class for
ArgumentConverter
implementations that always convert objects of a
given source type into a given target type.- Since:
- 5.7
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
TypedArgumentConverter
(Class<S> sourceType, Class<T> targetType) Create a newTypedArgumentConverter
. -
Method Summary
Modifier and TypeMethodDescriptionfinal Object
convert
(Object source, ParameterContext context) Convert the suppliedsource
object according to the suppliedcontext
.final Object
convert
(Object source, FieldContext context) Convert the suppliedsource
object according to the suppliedcontext
.protected abstract T
Convert the suppliedsource
object of typeS
into an object of typeT
.
-
Constructor Details
-
TypedArgumentConverter
Create a newTypedArgumentConverter
.- Parameters:
sourceType
- the type of the argument to convert; nevernull
targetType
- the type of the target object to create from the source; nevernull
-
-
Method Details
-
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 supplied; 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
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 field context where the converted object will be injected; 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
Convert the suppliedsource
object of typeS
into an object of typeT
.- Parameters:
source
- the source object to convert; may benull
- 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
-