Interface TypeConverterRegistry

All Superinterfaces:
AutoCloseable, CamelContextAware, HasCamelContext, Service, StaticService

public interface TypeConverterRegistry extends StaticService, CamelContextAware
Registry for type converters.

The utilization TypeConverterRegistry.Statistics is by default disabled, as it has a slight performance impact under very high concurrent load. The statistics can be enabled using CamelContext.setTypeConverterStatisticsEnabled(Boolean) (boolean)} method.

  • Method Details

    • addBulkTypeConverters

      void addBulkTypeConverters(BulkTypeConverters bulkTypeConverters)
      Registers a new set of type converters that are bulked together into a single BulkTypeConverters class.
    • addTypeConverter

      void addTypeConverter(Class<?> toType, Class<?> fromType, TypeConverter typeConverter)
      Registers a new type converter.

      This method may throw TypeConverterExistsException if configured to fail if an existing type converter already exists

      Parameters:
      toType - the type to convert to
      fromType - the type to convert from
      typeConverter - the type converter to use
    • removeTypeConverter

      boolean removeTypeConverter(Class<?> toType, Class<?> fromType)
      Removes the type converter
      Parameters:
      toType - the type to convert to
      fromType - the type to convert from
      Returns:
      true if removed, false if the type converter didn't exist
    • addTypeConverters

      void addTypeConverters(Object typeConverters)
      Registers all the type converters from the instance, each converter must be implemented as a method and annotated with Converter.
      Parameters:
      typeConverters - instance which implements the type converters
    • addFallbackTypeConverter

      void addFallbackTypeConverter(TypeConverter typeConverter, boolean canPromote)
      Registers a new fallback type converter
      Parameters:
      typeConverter - the type converter to use
      canPromote - whether or not the fallback type converter can be promoted to a first class type converter
    • lookup

      TypeConverter lookup(Class<?> toType, Class<?> fromType)
      Performs a lookup for a given type converter.
      Parameters:
      toType - the type to convert to
      fromType - the type to convert from
      Returns:
      the type converter or null if not found.
    • setInjector

      void setInjector(Injector injector)
      Sets the injector to be used for creating new instances during type conversions.
      Parameters:
      injector - the injector
    • getInjector

      Injector getInjector()
      Gets the injector
      Returns:
      the injector
    • getStatistics

      Gets the utilization statistics of this type converter registry
      Returns:
      the utilization statistics
    • size

      int size()
      Number of type converters in the registry.
      Returns:
      number of type converters in the registry.
    • getTypeConverterExistsLoggingLevel

      LoggingLevel getTypeConverterExistsLoggingLevel()
      The logging level to use when logging that a type converter already exists when attempting to add a duplicate type converter.

      The default logging level is DEBUG

    • setTypeConverterExistsLoggingLevel

      void setTypeConverterExistsLoggingLevel(LoggingLevel typeConverterExistsLoggingLevel)
      The logging level to use when logging that a type converter already exists when attempting to add a duplicate type converter.

      The default logging level is DEBUG

    • getTypeConverterExists

      TypeConverterExists getTypeConverterExists()
      What should happen when attempting to add a duplicate type converter.

      The default behavior is to ignore the duplicate.

    • setTypeConverterExists

      void setTypeConverterExists(TypeConverterExists typeConverterExists)
      What should happen when attempting to add a duplicate type converter.

      The default behavior is to ignore the duplicate.

    • addConverter

      default void addConverter(TypeConvertible<?,?> typeConvertible, TypeConverter typeConverter)
      Adds a type convertible pair to the registry
      Parameters:
      typeConvertible - A type convertible pair
      typeConverter - The type converter to associate with the type convertible pair