Class StandardTypeConverter
java.lang.Object
org.springframework.expression.spel.support.StandardTypeConverter
- All Implemented Interfaces:
TypeConverter
Default implementation of the
TypeConverter interface,
delegating to a core Spring ConversionService.- Since:
- 3.0
- Author:
- Juergen Hoeller, Andy Clement
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a StandardTypeConverter for the default ConversionService.StandardTypeConverter(Supplier<ConversionService> conversionService) Create a StandardTypeConverter for the given ConversionService.StandardTypeConverter(ConversionService conversionService) Create a StandardTypeConverter for the given ConversionService. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanConvert(TypeDescriptor sourceType, TypeDescriptor targetType) Returntrueif the type converter can convert the specified type to the desired target type.convertValue(Object value, TypeDescriptor sourceType, TypeDescriptor targetType) Convert (or coerce) a value from one type to another, for example from abooleanto aString.
-
Constructor Details
-
StandardTypeConverter
public StandardTypeConverter()Create a StandardTypeConverter for the default ConversionService. -
StandardTypeConverter
Create a StandardTypeConverter for the given ConversionService.- Parameters:
conversionService- the ConversionService to delegate to
-
StandardTypeConverter
Create a StandardTypeConverter for the given ConversionService.- Parameters:
conversionService- a Supplier for the ConversionService to delegate to- Since:
- 5.3.11
-
-
Method Details
-
canConvert
Description copied from interface:TypeConverterReturntrueif the type converter can convert the specified type to the desired target type.- Specified by:
canConvertin interfaceTypeConverter- Parameters:
sourceType- a type descriptor that describes the source typetargetType- a type descriptor that describes the requested result type- Returns:
trueif that conversion can be performed
-
convertValue
@Nullable public Object convertValue(@Nullable Object value, @Nullable TypeDescriptor sourceType, TypeDescriptor targetType) Description copied from interface:TypeConverterConvert (or coerce) a value from one type to another, for example from abooleanto aString.The
TypeDescriptorparameters enable support for typed collections: A caller may prefer aList<Integer>, for example, rather than simply anyList.- Specified by:
convertValuein interfaceTypeConverter- Parameters:
value- the value to be convertedsourceType- a type descriptor that supplies extra information about the source objecttargetType- a type descriptor that supplies extra information about the requested result type- Returns:
- the converted value
-