I have a class that belongs to a third-party library that I don't have access to. It looks like:
public class Product {
private String thumbnailUrl;
// many other properties, some of which are POJOs or collections
public String getThumbnailUrl() {
return thumbnailUrl;
}
public void setThumbnailUrl(String thumbnailUrl) {
this.thumbnailUrl = thumbnailUrl;
}
}
This is only one of the classes that I am going to serialize into string using Jackson. There are quite a few others.
The thumbnailUrl property can sometimes be null. How can I configure an ObjectMapper to serialize this field as http://www.example.com/unknown.png, if it is null?
I think I cannot use mixins as mixins won't have access to the original object hence they can't check if the value of the property is null or not.