Module org.junit.jupiter.params
Class DefaultArgumentConverter
- java.lang.Object
-
- org.junit.jupiter.params.converter.DefaultArgumentConverter
-
- All Implemented Interfaces:
ArgumentConverter
@API(status=INTERNAL, since="5.0") public class DefaultArgumentConverter extends java.lang.Object implements ArgumentConverter
DefaultArgumentConverter
is the default implementation of theArgumentConverter
API.The
DefaultArgumentConverter
is able to convert from strings to a number of primitive types and their corresponding wrapper types (Byte, Short, Integer, Long, Float, and Double), date and time types from thejava.time
package, and some additional common Java types such asFile
,BigDecimal
,BigInteger
,Currency
,Locale
,URI
,URL
,UUID
, etc.If the source and target types are identical the source object will not be modified.
- Since:
- 5.0
- See Also:
ArgumentConverter
-
-
Field Summary
Fields Modifier and Type Field Description static DefaultArgumentConverter
INSTANCE
private static java.util.List<StringToObjectConverter>
stringToObjectConverters
-
Constructor Summary
Constructors Modifier Constructor Description private
DefaultArgumentConverter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
convert(java.lang.Object source, java.lang.Class<?> targetType, ParameterContext context)
java.lang.Object
convert(java.lang.Object source, ParameterContext context)
Convert the suppliedsource
object according to the suppliedcontext
.private static java.lang.Class<?>
toWrapperType(java.lang.Class<?> targetType)
-
-
-
Field Detail
-
INSTANCE
public static final DefaultArgumentConverter INSTANCE
-
stringToObjectConverters
private static final java.util.List<StringToObjectConverter> stringToObjectConverters
-
-
Method Detail
-
convert
public final java.lang.Object convert(java.lang.Object source, ParameterContext context)
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
-
convert
public final java.lang.Object convert(java.lang.Object source, java.lang.Class<?> targetType, ParameterContext context)
-
toWrapperType
private static java.lang.Class<?> toWrapperType(java.lang.Class<?> targetType)
-
-