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.
|
void |
reset()
Reset internal state.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
convert, convert, convert, convertRequired, convertRequired
public <T> Optional<T> convert(Object object, 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(Class<S> sourceType, 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(Class<S> sourceType, 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(Class<S> sourceType, Class<T> targetType, 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 converter@Internal public void reset()
protected void registerDefaultConverters()
protected <T> TypeConverter findTypeConverter(Class<?> sourceType, Class<T> targetType, String formattingAnnotation)
T
- Generic typesourceType
- sourceTypetargetType
- targetTypeformattingAnnotation
- formattingAnnotation