Class ConverterManagerImpl
- java.lang.Object
-
- org.springframework.ldap.odm.typeconversion.impl.ConverterManagerImpl
-
- All Implemented Interfaces:
ConverterManager
public final class ConverterManagerImpl extends java.lang.Object implements ConverterManager
An implementation ofConverterManager.The algorithm used is to:
- Try to find and use a
Converterregistered for thefromClass,syntaxandtoClassand use it. - If this fails, then if the
toClass isAssignableFromthefromClassthen just assign it. - If this fails try to find and use a
Converterregistered for thefromClassand thetoClassignoring thesyntax. - If this fails then throw a
ConverterException.
-
-
Constructor Summary
Constructors Constructor Description ConverterManagerImpl()Create an empty ConverterManagerImpl
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConverter(java.lang.Class<?> fromClass, java.lang.String syntax, java.lang.Class<?> toClass, Converter converter)Add aConverterto thisConverterManager.booleancanConvert(java.lang.Class<?> fromClass, java.lang.String syntax, java.lang.Class<?> toClass)Determine whether this converter manager is able to carry out a specified conversion.<T> Tconvert(java.lang.Object source, java.lang.String syntax, java.lang.Class<T> toClass)Convert a given source object with an optional LDAP syntax to an instance of a given class.
-
-
-
Method Detail
-
canConvert
public boolean canConvert(java.lang.Class<?> fromClass, java.lang.String syntax, java.lang.Class<?> toClass)Description copied from interface:ConverterManagerDetermine whether this converter manager is able to carry out a specified conversion.- Specified by:
canConvertin interfaceConverterManager- Parameters:
fromClass- Convert from thefromClass.syntax- Using the LDAP syntax (may be null).toClass- To thetoClass.- Returns:
Trueif the conversion is supported,falseotherwise.
-
convert
public <T> T convert(java.lang.Object source, java.lang.String syntax, java.lang.Class<T> toClass)Description copied from interface:ConverterManagerConvert a given source object with an optional LDAP syntax to an instance of a given class.- Specified by:
convertin interfaceConverterManager- Type Parameters:
T- The class to convert to.- Parameters:
source- The object to convert.syntax- The LDAP syntax to use (may be null).toClass- The class to convert to.- Returns:
- The converted object.
-
addConverter
public void addConverter(java.lang.Class<?> fromClass, java.lang.String syntax, java.lang.Class<?> toClass, Converter converter)Add aConverterto thisConverterManager.- Parameters:
fromClass- The class theConvertershould be used to convert from.syntax- The LDAP syntax that theConvertershould be used for.toClass- The class theConvertershould be used to convert to.converter- TheConverterto add.
-
-