public class DefaultConversionService extends Object implements ConversionService<DefaultConversionService>
SHARED| Constructor and Description |
|---|
DefaultConversionService()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
<S,T> DefaultConversionService |
addConverter(Class<S> sourceType,
Class<T> targetType,
Function<S,T> function)
Adds a type converter.
|
<S,T> DefaultConversionService |
addConverter(Class<S> sourceType,
Class<T> targetType,
TypeConverter<S,T> typeConverter)
Adds a type converter.
|
<S,T> boolean |
canConvert(Class<S> sourceType,
Class<T> targetType)
Return whether the given source type is convertible to the given target type.
|
<T> Optional<T> |
convert(Object object,
Class<T> targetType,
ConversionContext context)
Attempts to convert the given object to the given target type.
|
protected <T> TypeConverter |
findTypeConverter(Class<?> sourceType,
Class<T> targetType,
String formattingAnnotation)
Find the type converter.
|
protected void |
registerDefaultConverters()
Default Converters.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconvert, convert, convert, convertRequired, convertRequiredpublic <T> Optional<T> convert(Object object, Class<T> targetType, ConversionContext context)
ConversionServiceOptional is returned.convert in interface ConversionService<DefaultConversionService>T - The generic typeobject - The object to converttargetType - The target typecontext - The conversion contextpublic <S,T> boolean canConvert(Class<S> sourceType, Class<T> targetType)
ConversionServicecanConvert in interface ConversionService<DefaultConversionService>S - The generic source typeT - The target source typesourceType - The source typetargetType - The target typepublic <S,T> DefaultConversionService addConverter(Class<S> sourceType, Class<T> targetType, TypeConverter<S,T> typeConverter)
ConversionServiceaddConverter in interface ConversionService<DefaultConversionService>S - The source generic typeT - The target generic typesourceType - The source typetargetType - The target typetypeConverter - The type converterpublic <S,T> DefaultConversionService addConverter(Class<S> sourceType, Class<T> targetType, Function<S,T> function)
ConversionServiceaddConverter in interface ConversionService<DefaultConversionService>S - The source generic typeT - The target generic typesourceType - The source typetargetType - The target typefunction - The type converterprotected void registerDefaultConverters()
protected <T> TypeConverter findTypeConverter(Class<?> sourceType, Class<T> targetType, String formattingAnnotation)
T - Generic typesourceType - sourceTypetargetType - targetTypeformattingAnnotation - formattingAnnotation