@API(status=INTERNAL, since="5.0") public class DefaultArgumentConverter extends SimpleArgumentConverter
DefaultArgumentConverter
is the default implementation of the
ArgumentConverter
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) as well as date and time types from the
java.time
package.
If the source and target types are identical the source object will not be modified.
ArgumentConverter
Modifier and Type | Class and Description |
---|---|
(package private) static class |
DefaultArgumentConverter.StringToEnumConverter |
(package private) static class |
DefaultArgumentConverter.StringToJavaTimeConverter |
(package private) static interface |
DefaultArgumentConverter.StringToObjectConverter |
(package private) static class |
DefaultArgumentConverter.StringToPrimitiveConverter |
Modifier and Type | Field and Description |
---|---|
static DefaultArgumentConverter |
INSTANCE |
private static java.util.List<DefaultArgumentConverter.StringToObjectConverter> |
stringToObjectConverters |
Modifier | Constructor and Description |
---|---|
private |
DefaultArgumentConverter() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
convert(java.lang.Object source,
java.lang.Class<?> targetType)
Convert the supplied
source object into to the supplied
targetType . |
private java.lang.Object |
convertToTargetType(java.lang.Object source,
java.lang.Class<?> targetType) |
private java.lang.Class<?> |
toWrapperType(java.lang.Class<?> targetType) |
convert
public static final DefaultArgumentConverter INSTANCE
private static final java.util.List<DefaultArgumentConverter.StringToObjectConverter> stringToObjectConverters
protected java.lang.Object convert(java.lang.Object source, java.lang.Class<?> targetType)
SimpleArgumentConverter
source
object into to the supplied
targetType
.convert
in class SimpleArgumentConverter
source
- the source object to convert; may be null
targetType
- the target type the source object should be converted
into; never null
null
but only if the target
type is a reference type.private java.lang.Class<?> toWrapperType(java.lang.Class<?> targetType)
private java.lang.Object convertToTargetType(java.lang.Object source, java.lang.Class<?> targetType)