I have two Objects Source and Target both with the same field names and types.
If a source field is null I would like the target to be "" (Empty String)
My Interface mapping looks like this (This is just two field, I have many)
@Mapper(componentModel = "spring", nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT)
public interface MyMapper {
@Mappings({
@Mapping(target="medium", defaultExpression="java(\"\")"),
@Mapping(target="origin", defaultExpression="java(\"\")")
})
public Target mapFrom(Source source)
If the Source has a value it should be copied across, if it is null in the source it should be "" in the target.
Mapstruct-1.3.0 seems to just keep everything null.
Any Idea? I would like default to be empty String for everything
@Mapperannotation. Refer to mapstruct.org/documentation/stable/reference/html/… - Nikolai Shevchenko