public class ConverterManager extends ChainableConversionService implements ConverterRegistry, Converter<Object,Object>, ConversionService, StringConverter
converterFor(Class, Class)
and if no such converter registered fallback will be returned.
DefaultConverter is the default fallback.fallback| Constructor and Description |
|---|
ConverterManager() |
ConverterManager(ConversionService fallback) |
| Modifier and Type | Method and Description |
|---|---|
<I,O> O |
convert(I src,
Class<O> dstType) |
Object |
convert(Object src,
TypeInfo<Object> srcType,
TypeInfo<Object> dstType)
Converter from SrcType to DstType.
|
<I,O,T extends Converter<I,O>> |
converterByType(Class<T> converterClass)
Get converter instance by converter class.
|
<SrcType,DstType> |
converterFor(Class<SrcType> srcType,
Class<DstType> dstType)
Lookup exact converter for the specified raw types.
|
<I,O> O |
convertType(I src,
TypeInfo<I> srcType,
TypeInfo<O> dstType)
Convert source value of specified type to value of destination type
|
<T> T |
fromString(TypeInfo<T> type,
String value)
Create new instance of expected type from string value
|
<SrcType,DstType> |
register(Class<SrcType> srcType,
Class<DstType> dstType,
Converter<SrcType,DstType> converter) |
<SrcType,DstType> |
register(Class<SrcType> srcType,
Class<DstType> dstType,
TwoWayConverter<SrcType,DstType> converter) |
<SrcType,DstType> |
register(Converter<SrcType,DstType> converter) |
<T> String |
toString(TypeInfo<T> type,
T value)
Convert object to string.
|
getFallbackpublic ConverterManager()
public ConverterManager(ConversionService fallback)
public <SrcType,DstType> Converter<SrcType,DstType> converterFor(Class<SrcType> srcType, Class<DstType> dstType)
ConversionServiceconverterFor in interface ConversionServicesrcType - source typedstType - destination typepublic <SrcType,DstType> void register(Class<SrcType> srcType, Class<DstType> dstType, Converter<SrcType,DstType> converter)
register in interface ConverterRegistrypublic <SrcType,DstType> void register(Class<SrcType> srcType, Class<DstType> dstType, TwoWayConverter<SrcType,DstType> converter)
register in interface ConverterRegistrypublic <SrcType,DstType> void register(Converter<SrcType,DstType> converter)
register in interface ConverterRegistrypublic <I,O> O convert(I src,
Class<O> dstType)
throws ConversionException
ConversionExceptionpublic <I,O> O convertType(I src,
TypeInfo<I> srcType,
TypeInfo<O> dstType)
throws ConversionException
ConversionServiceconvertType in interface ConversionServicesrc - source valuesrcType - extended source typedstType - destination typeConversionExceptionpublic Object convert(Object src, TypeInfo<Object> srcType, TypeInfo<Object> dstType) throws ConversionException
Convertersrc.getClass().isAssignableFrom(srcType) == true
* DstType class is assignable from returned objectconvert in interface Converter<Object,Object>src - source objectsrcType - source object type infodstType - destination object type infoConversionExceptionpublic <I,O,T extends Converter<I,O>> T converterByType(Class<T> converterClass)
converterByType in interface ConversionServiceT - generic converter target typeI - type of the source what converter supportsconverterClass - Converter class to instantiatepublic <T> T fromString(TypeInfo<T> type, String value) throws ConversionException
StringConverterfromString in interface StringConvertertype - Expected target typevalue - String value to convertConversionException - if something goes wrongpublic <T> String toString(TypeInfo<T> type, T value) throws ConversionException
StringConvertertoString in interface StringConvertertype - type info of valuevalue - Object to convert @return stringConversionException - if something goes wrongCopyright © 2016. All rights reserved.