Class DefaultArgumentConverter
- java.lang.Object
-
- org.junit.jupiter.params.converter.SimpleArgumentConverter
-
- org.junit.jupiter.params.converter.DefaultArgumentConverter
-
- All Implemented Interfaces:
ArgumentConverter
@API(status=INTERNAL, since="5.0") public class DefaultArgumentConverter extends SimpleArgumentConverterDefaultArgumentConverteris the default implementation of theArgumentConverterAPI.The
DefaultArgumentConverteris 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.timepackage, 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classDefaultArgumentConverter.StringToCommonJavaTypesConverterprivate static classDefaultArgumentConverter.StringToEnumConverterprivate static classDefaultArgumentConverter.StringToJavaTimeConverter(package private) static interfaceDefaultArgumentConverter.StringToObjectConverterprivate static classDefaultArgumentConverter.StringToPrimitiveConverter
-
Field Summary
Fields Modifier and Type Field Description static DefaultArgumentConverterINSTANCEprivate static java.util.List<DefaultArgumentConverter.StringToObjectConverter>stringToObjectConverters
-
Constructor Summary
Constructors Modifier Constructor Description privateDefaultArgumentConverter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectconvert(java.lang.Object source, java.lang.Class<?> targetType)Convert the suppliedsourceobject into the suppliedtargetType.private java.lang.ObjectconvertToTargetType(java.lang.Object source, java.lang.Class<?> targetType)private static java.lang.Class<?>toWrapperType(java.lang.Class<?> targetType)-
Methods inherited from class org.junit.jupiter.params.converter.SimpleArgumentConverter
convert
-
-
-
-
Field Detail
-
INSTANCE
public static final DefaultArgumentConverter INSTANCE
-
stringToObjectConverters
private static final java.util.List<DefaultArgumentConverter.StringToObjectConverter> stringToObjectConverters
-
-
Method Detail
-
convert
public java.lang.Object convert(java.lang.Object source, java.lang.Class<?> targetType)Description copied from class:SimpleArgumentConverterConvert the suppliedsourceobject into the suppliedtargetType.- Specified by:
convertin classSimpleArgumentConverter- Parameters:
source- the source object to convert; may benulltargetType- the target type the source object should be converted into; nevernull- Returns:
- the converted object; may be
nullbut only if the target type is a reference type
-
convertToTargetType
private java.lang.Object convertToTargetType(java.lang.Object source, java.lang.Class<?> targetType)
-
toWrapperType
private static java.lang.Class<?> toWrapperType(java.lang.Class<?> targetType)
-
-