Class ConverterProvider


  • public class ConverterProvider
    extends Object
    Centralized class for providing DEFAULT converters. All converters in this provider will ALWAYS be applied per default. To use a different converter you can override with the @Converter annotaiton To prevent a field from converting simply add @Converter with the converter field NOT SET.
    Since:
    1.0
    Author:
    Oliver Krauss
    • Field Detail

      • ARRAY_CONVERTER_ID

        public static final Class ARRAY_CONVERTER_ID
    • Constructor Detail

      • ConverterProvider

        public ConverterProvider()
    • Method Detail

      • init

        public static Map<Class,​Class<? extends FieldConverter>> init​(Map<Class,​Class<? extends FieldConverter>> converterMap)
        Init function provides converters. ALWAYS provides a default, even without spring context. Can be overriden with Spring by supplying a converter map, or during runtime by using this function
        Parameters:
        converterMap - to be provided instead of the hardcoded defaults
        Returns:
        default converter map
      • init

        public static Map<Class,​Class<? extends FieldConverter>> init​(Map<Class,​Class<? extends FieldConverter>> converterMap,
                                                                            boolean defaults)
        Init function provides converters. ALWAYS provides a default, even without spring context. Can be overriden with Spring by supplying a converter map, or during runtime by using this function
        Parameters:
        converterMap - to be provided instead of the hardcoded defaults
        defaults - if the default converter shall still be added (will NOT override anything in converterMap)
        Returns:
        default converter map
      • getConverter

        public static FieldConverter getConverter​(Class fieldClass,
                                                  Type type,
                                                  Map<Class,​Class<? extends FieldConverter>> converterOverrides)
        Returns converter for class
        Parameters:
        fieldClass - class that actually needs to be converted
        type - generic type (optional) of field
        converterOverrides - overrides for (sub) classes that shall be returned in the converter hierarchy instead
        Returns:
        converter (with possible sub-converters)