Looks like the solution is to set the value of the properties inside the default constructor. So in this case the java class is:
class JavaObject {
public JavaObject() {
optionalMember = "Value";
}
@NotNull
public String notNullMember;
public String optionalMember;
}
After the mapping with Jackson, if the optionalMember
is missing from the JSON its value in the Java class is "Value"
.
However, I am still interested to know if there is a solution with annotations and without the default constructor.