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));
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…