Nil values in mandatory properties

Apache SIS allows any metadata property to be null (for values that are not collections) or an empty collection. However, ISO 19115 defines some properties as mandatory. For example, the title of a Citation is mandatory, while the edition is optional. Apache SIS will not raise any warning or error if a mandatory property is missing. But for strict ISO compliance, the reason why the property is missing should be provided. Predefined reasons are:

Predefined nil reasons from ISO 19115-3
Reason Explanation
inapplicable The property is not applicable.
unknown The value probably exists but is not known.
missing The value cannot exist.
withheld The value cannot be revealed.
template The value will be available later.
other None of the above. Can be completed by user-suplied strings.

The transmission of this information requires the use of a non-null object, even when the value is missing. In such case, Apache SIS will return an object that, besides implementing the desired GeoAPI interface, also implements the NilObject interface. This interface flags the instances where all methods return an empty collection, an empty table, null, NaN, 0 or false, in this preference order, as permitted by the return types of the methods. Each instance that implements NilObject provides a getNilReason() method indicating why the object is nil. For example, the following code specifies that a citation title is missing because this metadata is only a template to be completed by the user:

import org.opengis.util.InternationalString;
import org.apache.sis.metadata.iso.citation.DefaultCitation;
import org.apache.sis.xml.NilReason;

void main() {
    InternationalString nil = NilReason.TEMPLATE.createNilObject(InternationalString.class);
    var citation = new DefaultCitation(nil);

    // Verify the reason that we have just set.
    System.out.println("Title: " + citation.getTitle());
    NilReason reason = NilReason.forObject(citation.getTitle());
    System.out.println("Reason why the title is missing: " + reason);
}

Output is as below (note that the title is empty, not null):

Title:
Reason why the title is missing: template