Class ConverterManagerImpl
java.lang.Object
org.springframework.ldap.odm.typeconversion.impl.ConverterManagerImpl
- All Implemented Interfaces:
ConverterManager
An implementation of
ConverterManager
.
The algorithm used is to:
- Try to find and use a
Converter
registered for thefromClass
,syntax
andtoClass
and use it. - If this fails, then if the
toClass isAssignableFrom
thefromClass
then just assign it. - If this fails try to find and use a
Converter
registered for thefromClass
and thetoClass
ignoring thesyntax
. - If this fails then throw a
ConverterException
.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConverter
(Class<?> fromClass, String syntax, Class<?> toClass, Converter converter) Add aConverter
to thisConverterManager
.boolean
canConvert
(Class<?> fromClass, String syntax, Class<?> toClass) Determine whether this converter manager is able to carry out a specified conversion.<T> T
Convert a given source object with an optional LDAP syntax to an instance of a given class.
-
Constructor Details
-
ConverterManagerImpl
public ConverterManagerImpl()Create an empty ConverterManagerImpl
-
-
Method Details
-
canConvert
Description copied from interface:ConverterManager
Determine whether this converter manager is able to carry out a specified conversion.- Specified by:
canConvert
in interfaceConverterManager
- Parameters:
fromClass
- Convert from thefromClass
.syntax
- Using the LDAP syntax (may be null).toClass
- To thetoClass
.- Returns:
True
if the conversion is supported,false
otherwise.
-
convert
Description copied from interface:ConverterManager
Convert a given source object with an optional LDAP syntax to an instance of a given class.- Specified by:
convert
in 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
Add aConverter
to thisConverterManager
.- Parameters:
fromClass
- The class theConverter
should be used to convert from.syntax
- The LDAP syntax that theConverter
should be used for.toClass
- The class theConverter
should be used to convert to.converter
- TheConverter
to add.
-