@ -27,7 +27,12 @@ public interface ConversionService {
@@ -27,7 +27,12 @@ public interface ConversionService {
/ * *
* Returns true if objects of sourceType can be converted to targetType .
* @param sourceType the source type to convert from ( required )
* If this method returns true , it means { @link # convert ( Object , Class ) } is capable of converting an instance of sourceType to targetType .
* Special note on collections , arrays , and maps types :
* For conversion between collection , array , and map types , this method will return ' true '
* even though a convert invocation may still generate a { @link ConversionException } if the underlying elements are not convertible .
* Callers are expected to handle this exceptional case when working with collections and maps .
* @param sourceType the source type to convert from ( may be null if source is null )
* @param targetType the target type to convert to ( required )
* @return true if a conversion can be performed , false if not
* @throws IllegalArgumentException if targetType is null
@ -36,12 +41,16 @@ public interface ConversionService {
@@ -36,12 +41,16 @@ public interface ConversionService {
/ * *
* Returns true if objects of sourceType can be converted to the targetType .
* The TypeDescriptors provide additional context about the source and target locations where conversion would occur , often object property locations .
* @param sourceType context about the source type to convert from ( required )
* The TypeDescriptors provide additional context about the source and target locations where conversion would occur , often object fields or property locations .
* If this method returns true , it means { @link # convert ( Object , TypeDescriptor , TypeDescriptor ) } is capable of converting an instance of sourceType to targetType .
* Special note on collections , arrays , and maps types :
* For conversion between collection , array , and map types , this method will return ' true '
* even though a convert invocation may still generate a { @link ConversionException } if the underlying elements are not convertible .
* Callers are expected to handle this exceptional case when working with collections and maps .
* @param sourceType context about the source type to convert from ( may be null if source is null )
* @param targetType context about the target type to convert to ( required )
* @return true if a conversion can be performed between the source and target types , false if not
* @throws IllegalArgumentException if targetType is null
* @see TypeDescriptor # forObject ( Object )
* /
boolean canConvert ( TypeDescriptor sourceType , TypeDescriptor targetType ) ;
@ -57,7 +66,7 @@ public interface ConversionService {
@@ -57,7 +66,7 @@ public interface ConversionService {
/ * *
* Convert the source to targetType .
* The TypeDescriptors provide additional context about the source and target locations where conversion will occur , often object property locations .
* The TypeDescriptors provide additional context about the source and target locations where conversion will occur , often object fields or property locations .
* @param source the source object to convert ( may be null )
* @param sourceType context about the source type converting from ( may be null if source is null )
* @param targetType context about the target type to convert to ( required )
@ -65,7 +74,6 @@ public interface ConversionService {
@@ -65,7 +74,6 @@ public interface ConversionService {
* @throws ConversionException if a conversion exception occurred
* @throws IllegalArgumentException if targetType is null
* @throws IllegalArgumentException if sourceType is null but source is not null
* @see TypeDescriptor # forObject ( Object )
* /
Object convert ( Object source , TypeDescriptor sourceType , TypeDescriptor targetType ) ;