Package org.springframework.expression.spel.support

# Class StandardTypeConverter

java.lang.Object
org.springframework.expression.spel.support.StandardTypeConverter

All Implemented Interfaces:
  `TypeConverter`

public class StandardTypeConverter extends Object implements TypeConverter
Default implementation of the `TypeConverter` interface, delegating to a core Spring `ConversionService`.

Since:
  3.0
Author:
  Juergen Hoeller, Andy Clement
See Also:
  - `ConversionService`

## Constructor Summary

Constructors
Constructor
Description
`StandardTypeConverter()`
Create a StandardTypeConverter for the default ConversionService.
`StandardTypeConverter(Supplier<org.springframework.core.convert.ConversionService> conversionService)`
Create a StandardTypeConverter for the given ConversionService.
`StandardTypeConverter(org.springframework.core.convert.ConversionService conversionService)`
Create a StandardTypeConverter for the given ConversionService.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`canConvert(org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)`
Return `true` if the type converter can convert the specified type to the desired target type.
`Object`
`convertValue(Object value, org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)`
Convert (or coerce) a value from one type to another, for example from a `boolean` to a `String`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### StandardTypeConverter

public StandardTypeConverter()
Create a StandardTypeConverter for the default ConversionService.

See Also:
  - `DefaultConversionService.getSharedInstance()`

### StandardTypeConverter

public StandardTypeConverter(org.springframework.core.convert.ConversionService conversionService)
Create a StandardTypeConverter for the given ConversionService.

Parameters:
  `conversionService` - the ConversionService to delegate to

### StandardTypeConverter

public StandardTypeConverter(Supplier<org.springframework.core.convert.ConversionService> conversionService)
Create a StandardTypeConverter for the given ConversionService.

Parameters:
  `conversionService` - a Supplier for the ConversionService to delegate to
Since:
  5.3.11

## Method Details

### canConvert

public boolean canConvert(@Nullable org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
Description copied from interface: `TypeConverter`
Return `true` if the type converter can convert the specified type to the desired target type.

Specified by:
  `canConvert` in interface `TypeConverter`
Parameters:
  `sourceType` - a type descriptor that describes the source type
  `targetType` - a type descriptor that describes the requested result type
Returns:
  `true` if that conversion can be performed

### convertValue

@Nullable public Object convertValue(@Nullable Object value, @Nullable org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
Description copied from interface: `TypeConverter`
Convert (or coerce) a value from one type to another, for example from a `boolean` to a `String`.

The `TypeDescriptor` parameters enable support for typed collections: A caller may prefer a `List<Integer>`, for example, rather than simply any `List`.

Specified by:
  `convertValue` in interface `TypeConverter`
Parameters:
  `value` - the value to be converted
  `sourceType` - a type descriptor that supplies extra information about the source object
  `targetType` - a type descriptor that supplies extra information about the requested result type
Returns:
  the converted value