Module org.junit.jupiter.params
Class SimpleArgumentConverter
java.lang.Object
org.junit.jupiter.params.converter.SimpleArgumentConverter
- All Implemented Interfaces:
ArgumentConverter
@API(status=STABLE,
since="5.7")
public abstract class SimpleArgumentConverter
extends Object
implements ArgumentConverter
SimpleArgumentConverter
is an abstract base class for
ArgumentConverter
implementations that only need to know the target
type and do not need access to the ParameterContext
to perform the
conversion.- Since:
- 5.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract @Nullable Object
Convert the suppliedsource
object into the suppliedtargetType
.final @Nullable Object
convert
(@Nullable Object source, ParameterContext context) Convert the suppliedsource
object according to the suppliedcontext
.final @Nullable Object
convert
(@Nullable Object source, FieldContext context) Convert the suppliedsource
object according to the suppliedcontext
.
-
Constructor Details
-
SimpleArgumentConverter
public SimpleArgumentConverter()
-
-
Method Details
-
convert
public final @Nullable Object convert(@Nullable 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
public final @Nullable Object convert(@Nullable Object source, FieldContext 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 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
protected abstract @Nullable Object convert(@Nullable Object source, Class<?> targetType) throws ArgumentConversionException Convert the suppliedsource
object into the suppliedtargetType
.- Parameters:
source
- the source object to convert; may benull
targetType
- the target type the source object should be converted into; 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
-