The faq explains how to do this in XML. This shows how to do it per class using the API. The problem is you have to set it on on the class. What if I only want it on one field? Is this possible?
You don't need converter. Dozer allows to do it easily:
import static org.dozer.loader.api.TypeMappingOptions.mapNull;
import static org.dozer.loader.api.TypeMappingOptions.mapEmptyString;
...
public Mapper getMapper() {
DozerBeanMapper mapper = new DozerBeanMapper();
mapper.addMapping(beanMappingBuilder());
return mapper;
}
private BeanMappingBuilder beanMappingBuilder() {
return new BeanMappingBuilder() {
@Override
protected void configure() {
mapping(ClassA.class, ClassB.class, mapNull(false), mapEmptyString(false));
}
}
}