@Nullable (jakarta.annotation & org.jspecify.annotations)
Apache Causeway' defaults for properties and parameters is that they are mandatory unless otherwise stated.
Both the @jakarta.annotation.Nullable annotation and @org.jspecify.annotations.Nullable annotation are recognized by Apache Causeway for both properties and parameters as means to indicate that the property/parameter is not mandatory.
For example:
import jakarta.annotation.Nullable;
@Nullable
@Getter @Setter
private String name;
or:
import jakarta.annotation.Nullable;
public Customer updateName(
@Nullable final String name) {
setName(name);
return this;
}
Apache Causeway does provide several other ways to specify optionality: using the @Property#optionality() / @Parameter#optionality() annotation. For properties, the optionality can also be inferred from the JPA @Column#nullable() attribute.
|
See the @Property#optionality() documentation for a much fuller discussion on the relationship between using the Apache Causeway annotations vs @Column#nullable(). |
Metamodel validation during bootstrapping checks that there are no conflicting definitions of optionality.