The rules would not be very useful if all you could do was always protect or require properties. This behavior is usually based on conditions. Rules take as input one or more Conditions (for example, objects implementing the Condition interface). Right now, there are several conditions that can be used:
personNames
' size equals 0
would mean there are no names for a person). Finally, null values can be tested
using a special constant value Constant.NULL
. true
if each of them are true
. This is
evaluated lazily and will not even evaluate the second condition if the first
is false
(a performance enhancement). true
if either of them are true
. This is
evaluated lazily and will not even evaluate the second condition if the first
is true
(a performance enhancement). Each of these conditions is accessible from the corresponding property or condition. There should be no reason in normal development to use the constructors for the conditions above. Instead, you could say, for instance:
Condition isPrimaryName = PersonName.properties.isPrimaryName.isTrue();
or
Condition isAlias
= PersonName.properties.nameType.isEqualTo(NameTypeLookup.ALIAS);
or
Condition greaterThan
= PersonName.properties.sequence.isGreaterThan(BigInteger.ZERO);
or
Condition hasOnePrimaryName
= Person.properties.names.containsAtLeastOne(isPrimaryName);
or
Condition notAlias = isAlias.not();