Given the following example
public class Dto {
List<Long> longs = new ArrayList<>();
public List<Long> getLongs() {
return longs;
}
public void setLongs(List<Long> longs) {
this.longs = longs;
}
}
public class Entity {
List<Long> longs = new ArrayList<>();
public List<Long> getLongs() {
return longs;
}
public void setLongs(List<Long> longs) {
this.longs = longs;
}
}
@Mapper(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT)
public interface EntityMapper {
Dto asTarget(Entity entity);
}
The generated mapper looks like this:
public EntityMapperImpl() {
}
public Dto asTarget(Entity entity) {
Dto dto = new Dto();
if (entity != null) {
List<Long> list = entity.getLongs();
if (list != null) {
dto.setLongs(new ArrayList(list));
} else {
dto.setLongs((List)null);
}
}
return dto;
}
}
Shouldn't the list set to an empty list rather than null? Or do I have a misunderstanding of the null value mapping strategy?
Given the following example
The generated mapper looks like this:
Shouldn't the list set to an empty list rather than null? Or do I have a misunderstanding of the null value mapping strategy?