Interface Converter
- All Known Subinterfaces:
TwoWayConverter
- All Known Implementing Classes:
ArrayToArray
,ArrayToCollection
,CollectionToCollection
,DataModelConverter
,FormattedStringToNumber
,NumberToNumber
,ObjectToArray
,ObjectToCollection
,PropertyEditorConverter
,ReverseConverter
,SpringConvertingConverterAdapter
,StringToBigDecimal
,StringToBigInteger
,StringToBoolean
,StringToByte
,StringToCharacter
,StringToClass
,StringToDate
,StringToDouble
,StringToEnum
,StringToFloat
,StringToInteger
,StringToLocale
,StringToLong
,StringToObject
,StringToShort
public interface Converter
A converter is capable of converting a source object of type
getSourceClass()
to a target type of type
getTargetClass()
. If the converter is a TwoWayConverter
, it can also convert from the target back to
the source.
Implementations of this interface are thread-safe and can be shared.
- Author:
- Keith Donald
-
Method Summary
Modifier and TypeMethodDescriptionconvertSourceToTargetClass
(Object source, Class<?> targetClass) Convert the provided source object argument to an instance of the specified target class.Class<?>
The source class this converter can convert from.Class<?>
The target class this converter can convert to.
-
Method Details
-
getSourceClass
Class<?> getSourceClass()The source class this converter can convert from. May be an interface or abstract type to allow this converter to convert specific subclasses as well.- Returns:
- the source type
-
getTargetClass
Class<?> getTargetClass()The target class this converter can convert to. May be an interface or abstract type to allow this converter to convert specific subclasses as well.- Returns:
- the target type
-
convertSourceToTargetClass
Convert the provided source object argument to an instance of the specified target class.- Parameters:
source
- the source object to convert, which must be an instance ofgetSourceClass()
targetClass
- the target class to convert the source to, which must be equal to or a specialization ofgetTargetClass()
- Returns:
- the converted object, which must be an instance of the
targetClass
- Throws:
Exception
- an exception occurred performing the conversion
-