Class Converters

java.lang.Object
org.apache.ofbiz.base.conversion.Converters

public final class Converters extends Object
A Converter factory and repository.
  • Method Details

    • getConverter

      public static <S, T> Converter<S,T> getConverter(Class<S> sourceClass, Class<T> targetClass) throws ClassNotFoundException
      Returns an appropriate Converter instance for sourceClass and targetClass. If no matching Converter is found, the method throws ClassNotFoundException.

      This method is intended to be used when the source or target Object types are unknown at compile time. If the source and target Object types are known at compile time, then one of the "ready made" converters should be used.

      Parameters:
      sourceClass - The object class to convert from
      targetClass - The object class to convert to
      Returns:
      A matching Converter instance
      Throws:
      ClassNotFoundException
    • loadContainedConverters

      public static void loadContainedConverters(Class<?> containerClass)
      Load all classes that implement Converter and are contained in containerClass.
      Parameters:
      containerClass -
    • registerConverter

      public static <S, T> void registerConverter(Converter<S,T> converter)
      Registers a Converter instance to be used by the getConverter(Class, Class) method.
      Type Parameters:
      S - The source object type
      T - The target object type
      Parameters:
      converter - The Converter instance to register