Background
The runConditions method in TypeValidators currently accesses multi-cardinality typeAliases directly without checking for null. This results in a potential NullPointerException when invoking size() method on a null list.
Example Issue
final List<? extends FieldWithMetaString> businessCenter = o.getBusinessCenter();
for (int i = 0; i < businessCenter.size(); i++) {
// ...
}
If getBusinessCenter() returns null, the above code will throw a NullPointerException when size() is called. This scenario is common in multi-cardinality typeAliases with condition properties.
Proposed Solution
Introduce a null safety wrapper using Optional.ofNullable(...).orElse(...) to default to an empty list when the property is null.
final List<? extends FieldWithMetaString> businessCenter = Optional
.ofNullable(o.getBusinessCenter())
.orElse(new ArrayList<>());
for (int i = 0; i < businessCenter.size(); i++) {
// ...
}
PR: #1029