public class DefaultConversionService extends java.lang.Object implements ConversionService<DefaultConversionService>
SHARED
Constructor and Description |
---|
DefaultConversionService()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<S,T> DefaultConversionService |
addConverter(java.lang.Class<S> sourceType,
java.lang.Class<T> targetType,
java.util.function.Function<S,T> function)
Adds a type converter.
|
<S,T> DefaultConversionService |
addConverter(java.lang.Class<S> sourceType,
java.lang.Class<T> targetType,
TypeConverter<S,T> typeConverter)
Adds a type converter.
|
<S,T> boolean |
canConvert(java.lang.Class<S> sourceType,
java.lang.Class<T> targetType)
Return whether the given source type is convertible to the given target type.
|
<T> java.util.Optional<T> |
convert(java.lang.Object object,
java.lang.Class<T> targetType,
ConversionContext context)
Attempts to convert the given object to the given target type.
|
protected <T> TypeConverter |
findTypeConverter(java.lang.Class<?> sourceType,
java.lang.Class<T> targetType,
java.lang.String formattingAnnotation)
Find the type converter.
|
protected void |
registerDefaultConverters()
Default Converters.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
convert, convert, convert, convertRequired, convertRequired
public <T> java.util.Optional<T> convert(java.lang.Object object, java.lang.Class<T> targetType, ConversionContext context)
ConversionService
Optional
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(java.lang.Class<S> sourceType, java.lang.Class<T> targetType)
ConversionService
canConvert
in interface ConversionService<DefaultConversionService>
S
- The generic source typeT
- The target source typesourceType
- The source typetargetType
- The target typepublic <S,T> DefaultConversionService addConverter(java.lang.Class<S> sourceType, java.lang.Class<T> targetType, TypeConverter<S,T> typeConverter)
ConversionService
addConverter
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(java.lang.Class<S> sourceType, java.lang.Class<T> targetType, java.util.function.Function<S,T> function)
ConversionService
addConverter
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(java.lang.Class<?> sourceType, java.lang.Class<T> targetType, java.lang.String formattingAnnotation)
T
- Generic typesourceType
- sourceTypetargetType
- targetTypeformattingAnnotation
- formattingAnnotation