|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ConversionService
A service interface for type conversion. This is the entry point into the convert system.
Call convert(Object, Class)
to perform a thread-safe type conversion using this system.
Method Summary | ||
---|---|---|
boolean |
canConvert(Class<?> sourceType,
Class<?> targetType)
Returns true if objects of sourceType can be converted to targetType. |
|
boolean |
canConvert(TypeDescriptor sourceType,
TypeDescriptor targetType)
Returns true if objects of sourceType can be converted to the targetType. |
|
|
convert(Object source,
Class<T> targetType)
Convert the source to targetType. |
|
Object |
convert(Object source,
TypeDescriptor sourceType,
TypeDescriptor targetType)
Convert the source to targetType. |
Method Detail |
---|
boolean canConvert(Class<?> sourceType, Class<?> targetType)
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 ConversionException
if the underlying elements are not convertible.
Callers are expected to handle this exceptional case when working with collections and maps.
sourceType
- the source type to convert from (may be null if source is null)targetType
- the target type to convert to (required)
IllegalArgumentException
- if targetType is nullboolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType)
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 ConversionException
if the underlying elements are not convertible.
Callers are expected to handle this exceptional case when working with collections and maps.
sourceType
- context about the source type to convert from (may be null if source is null)targetType
- context about the target type to convert to (required)
IllegalArgumentException
- if targetType is null<T> T convert(Object source, Class<T> targetType)
source
- the source object to convert (may be null)targetType
- the target type to convert to (required)
ConversionException
- if a conversion exception occurred
IllegalArgumentException
- if targetType is nullObject convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType)
source
- the source object to convert (may be null)sourceType
- context about the source type converting from (may be null if source is null)targetType
- context about the target type to convert to (required)
targetType
ConversionException
- if a conversion exception occurred
IllegalArgumentException
- if targetType is null
IllegalArgumentException
- if sourceType is null but source is not null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |