Class StandardTypeConverter

    • Constructor Detail

      • StandardTypeConverter

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

        public StandardTypeConverter​(ConversionService conversionService)
        Create a StandardTypeConverter for the given ConversionService.
        Parameters:
        conversionService - the ConversionService to delegate to
    • Method Detail

      • canConvert

        public boolean canConvert​(TypeDescriptor sourceType,
                                  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

        public Object convertValue​(Object value,
                                   TypeDescriptor sourceType,
                                   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