How do a I configure Dozer so that it will only copy the value from one field in bean a to a field in bean b if the field in bean b is null? I am using dsl config
mapping(FirstGivingPayloadV1.Payload.class, Nonprofit.class, oneWay(),
mapNull(false), mapId("firstGivingPayloadV1"))
.fields("latitude", "latitude")
.fields("longitude", "longitude")
.fields("revoked", "isNonProfitStatusVerified");
.fields("url", "websiteUrl"); // only copy url if webSiteURL == null or is empty
Write a custom converter for this field conversion. Custom converter should check if field in bean
bis null and if it is copy fieldato it.From Dozer documentation:
In the example below, Dozer will invoke the custom converter to perform the field mapping.
In custom converter you have access to destination object and you can check if it is null, look at the
convertmethod signature: