DozerMapper / dozer

Dozer is a Java Bean to Java Bean mapper that recursively copies data from one object to another.
https://dozermapper.github.io/
Apache License 2.0
2.08k stars 481 forks source link

CustomConverter not able to be set by withCustomConverter within DozerBeanMapperBuilder #829

Closed am185652 closed 2 years ago

am185652 commented 3 years ago

Are you in the right place?

Whats your runtime?

Whats the problem?

When creating a builder, the function withcustomconverter does not set the value of customconverter. Steps to reproduce:

  1. Create DozerBeanMapperBuilder
  2. Use custom converter implemented from CustomConverter.

Observed Results:

What happened? This could be a description, log output, etc. customConverters = {ArrayList@16643} size = 0

Expected Results:

What did you expect to happen? I expect for the customconverter to be used within the mapper.

Link to GitHub repo with Unit test

The easiest way for us to fix issues, is if you provide a GitHub repo, using the latest release and a simple unit test.

garethahealy commented 3 years ago

like this?

am185652 commented 3 years ago

Yes. My implementation is `ItemCustomConverter customConverter = new ItemCustomConverter(objectMapper);

Mapper mapper = DozerBeanMapperBuilder .create() .withMappingBuilder(builder) .withCustomConverter(customConverter) .build();`

am185652 commented 3 years ago

This is my BeanMappingBuilder

BeanMappingBuilder builder = new BeanMappingBuilder() { protected void configure() { mapping(ClassA.class, ClassB.class, mapNull(false)); } }; I see a usage of customconverter within the field set, is that required for the customconverter to be set within the mapper creation?

am185652 commented 3 years ago

I guess another way to phrase my issue is I am trying to implement my own custom converter only using the API rather than the xml mappings. So is withCustomConverter supposed to be able to be used without the use of xml?

garethahealy commented 2 years ago

like this?