Am seeing behaviour I can't explain with ModelMapper
whilst trying to map a boolean to char.
(I have checked, and the problem isn't Lombok related).
@Data @NoArgsConstructor @AllArgsConstructor
public class Entity { private boolean instance; }
@Data @NoArgsConstructor @AllArgsConstructor
public class Item { private char instance; }
public final class ModelMapperTest
{
private final ModelMapper modelMapper = new ModelMapper();
@Before
public void before()
{
modelMapper.addMappings(new PropertyMap<Entity, Item>()
{
protected void configure()
{
map().setInstance(source.isInstance() ? 'Y' : 'N');
}
});
}
@Test
public void map()
{
for (final Item item : map(new ArrayList<Entity>()
{
{
this.add(new Entity(true));
this.add(new Entity(false));
}
}))
{
System.out.println(item);
}
}
public List<Item> map(final List<Entity> entities)
{
return modelMapper.map(entities, new TypeToken<List<Item>>(){}.getType());
}
}
Which produces characters 't' and 'f' not 'Y' and 'N' as I'd intended.
Item(instance=t)
Item(instance=f)
Anyone know how the ModelMapper
configuration should look?