org.springframework.core.convert.support

Class DefaultConversionService

    • Constructor Detail

      • DefaultConversionService

        public DefaultConversionService()
        Create a new DefaultConversionService with the set of default converters.
    • Method Detail

      • getSharedInstance

        public static ConversionService getSharedInstance()
        Return a shared default ConversionService instance, lazily building it once needed.

        NOTE: We highly recommend constructing individual ConversionService instances for customization purposes. This accessor is only meant as a fallback for code paths which need simple type coercion but cannot access a longer-lived ConversionService instance any other way.

        Returns:
        the shared ConversionService instance (never null)
        Since:
        4.3.5
      • addDefaultConverters

        public static void addDefaultConverters(ConverterRegistry converterRegistry)
        Add converters appropriate for most environments.
        Parameters:
        converterRegistry - the registry of converters to add to (must also be castable to ConversionService, e.g. being a ConfigurableConversionService)
        Throws:
        java.lang.ClassCastException - if the given ConverterRegistry could not be cast to a ConversionService
      • addCollectionConverters

        public static void addCollectionConverters(ConverterRegistry converterRegistry)
        Add common collection converters.
        Parameters:
        converterRegistry - the registry of converters to add to (must also be castable to ConversionService, e.g. being a ConfigurableConversionService)
        Throws:
        java.lang.ClassCastException - if the given ConverterRegistry could not be cast to a ConversionService
        Since:
        4.2.3