Class ApplicationConversionService

  • All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.context.EmbeddedValueResolverAware, org.springframework.core.convert.ConversionService, org.springframework.core.convert.converter.ConverterRegistry, org.springframework.core.convert.support.ConfigurableConversionService, org.springframework.format.FormatterRegistry

    public class ApplicationConversionService
    extends org.springframework.format.support.FormattingConversionService
    A specialization of FormattingConversionService configured by default with converters and formatters appropriate for most Spring Boot applications.

    Designed for direct instantiation but also exposes the static addApplicationConverters(org.springframework.core.convert.converter.ConverterRegistry) and addApplicationFormatters(FormatterRegistry) utility methods for ad-hoc use against registry instance.

    Since:
    2.0.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static voidaddApplicationConverters​(org.springframework.core.convert.converter.ConverterRegistry registry)
      Add converters useful for most Spring Boot applications.
      static voidaddApplicationFormatters​(org.springframework.format.FormatterRegistry registry)
      Add formatters useful for most Spring Boot applications.
      static voidaddDelimitedStringConverters​(org.springframework.core.convert.converter.ConverterRegistry registry)
      Add converters to support delimited strings.
      static voidconfigure​(org.springframework.format.FormatterRegistry registry)
      Configure the given FormatterRegistry with formatters and converters appropriate for most Spring Boot applications.
      static org.springframework.core.convert.ConversionServicegetSharedInstance()
      Return a shared default application ConversionService instance, lazily building it once needed.
      • Methods inherited from class org.springframework.format.support.FormattingConversionService

        addFormatter, addFormatterForFieldAnnotation, addFormatterForFieldType, addFormatterForFieldType, setEmbeddedValueResolver
      • Methods inherited from class org.springframework.core.convert.support.GenericConversionService

        addConverter, addConverter, addConverter, addConverterFactory, canBypassConvert, canConvert, canConvert, convert, convert, convert, convertNullSource, getConverter, getDefaultConverter, removeConvertible, toString
      • Methods inherited from interface org.springframework.core.convert.converter.ConverterRegistry

        addConverter, addConverter, addConverter, addConverterFactory, removeConvertible
    • Method Detail

      • getSharedInstance

        public static org.springframework.core.convert.ConversionService getSharedInstance()
        Return a shared default application ConversionService instance, lazily building it once needed.

        Note: This method actually returns an ApplicationConversionService instance. However, the ConversionService signature has been preserved for binary compatibility.

        Returns:
        the shared ApplicationConversionService instance (never null)
      • configure

        public static void configure​(org.springframework.format.FormatterRegistry registry)
        Configure the given FormatterRegistry with formatters and converters appropriate for most Spring Boot applications.
        Parameters:
        registry - the registry of converters to add to (must also be castable to ConversionService, e.g. being a ConfigurableConversionService)
        Throws:
        ClassCastException - if the given FormatterRegistry could not be cast to a ConversionService
      • addApplicationConverters

        public static void addApplicationConverters​(org.springframework.core.convert.converter.ConverterRegistry registry)
        Add converters useful for most Spring Boot applications.
        Parameters:
        registry - the registry of converters to add to (must also be castable to ConversionService, e.g. being a ConfigurableConversionService)
        Throws:
        ClassCastException - if the given ConverterRegistry could not be cast to a ConversionService
      • addDelimitedStringConverters

        public static void addDelimitedStringConverters​(org.springframework.core.convert.converter.ConverterRegistry registry)
        Add converters to support delimited strings.
        Parameters:
        registry - the registry of converters to add to (must also be castable to ConversionService, e.g. being a ConfigurableConversionService)
        Throws:
        ClassCastException - if the given ConverterRegistry could not be cast to a ConversionService
      • addApplicationFormatters

        public static void addApplicationFormatters​(org.springframework.format.FormatterRegistry registry)
        Add formatters useful for most Spring Boot applications.
        Parameters:
        registry - the service to register default formatters with