Class BaseConverter

  • All Implemented Interfaces:
    com.github.dozermapper.core.ConfigurableCustomConverter, com.github.dozermapper.core.CustomConverter
    Direct Known Subclasses:
    CustomMapper, ExpressionMapper, VariableMapper

    public abstract class BaseConverter
    extends Object
    implements com.github.dozermapper.core.ConfigurableCustomConverter
    Configurable converters in Dozer are not thread-safe if a single converter instance is used. One thread could step on the parameter being used by another thread since setParameter() is called first and convert() is called separately. This implementation holds a copy of the parameter in thread-local storage which eliminates the possibility of collision between threads on a single converter instance. Any converter which is referenced by ID with the Dozer component should extend this class. It is recommended to call done() in a finally block in the implementation of convert() to clean up the value stored in the thread local.
    • Constructor Detail

      • BaseConverter

        public BaseConverter()
    • Method Detail

      • setParameter

        public void setParameter​(String parameter)
        Specified by:
        setParameter in interface com.github.dozermapper.core.ConfigurableCustomConverter
      • done

        public void done()
      • getParameter

        public String getParameter()