Hi Karl,
It'd probably make sense to have some kind of global option for
controlling how to deal with empty strings.
But for the time being you could try it like this:
public interface MyMapper {
@Mapping(
target = "localDateTime",
expression = "java(emptyToNull(src.getDateString()))",
dateFormat = "yyyy-MM-dd:HH:mm"
)
Target toTarget(Source src);
default String emptyToNull(String s) {
return s == null || s.isEmpty() ? null : s;
}
}
I.e. feed the input property through some property which converts
empty strings to null before applying the mapping.
--Gunnar
2017-03-02 11:25 GMT+01:00 karl.w.roth via mapstruct-users
<
mapstru...@googlegroups.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "mapstruct-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
mapstruct-use...@googlegroups.com.
> To post to this group, send email to
mapstru...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.