Conditions
The rules wouldn't 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 (e.g. objects implementing the Condition interface). Right now, there are several conditions that can be used:
• Equals. This condition can compare properties to each other or to constants (lookup values, Strings, etc). Likewise, the size of a collection can be compared using Equals (e.g. determine 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".
• Not. This is the basic boolean operator that can change the value of other conditions.
• And. This is the basic boolean operator that takes two child condtions, and return true if each of them are true. This is evaluated "lazily" and won't even evaluate the second condition if the first is false (a performance enhancement).
• Or. This is the basic boolean operator that takes two child conditions, and return true if either of them are true. This is evaluated "lazily" and won't even evaluate the second condition if the first is true (a performance enhancement).
• GreaterThan / GreaterThanOrEquals. This evaluates whether one property/constant is greater than (or greater than or equal to) to another property/constant.
• LessThan / LessThanOrEquals. This evaluates whether one property/constant is less than (or less than or equal to) to another property/constant.
• Contains. These are conditions for a collection of children- at least one element has condition x, at most 2 elements match condition y, etc). The child condition's properties should be referenced from the point-of-view of the child row.
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();
Parent topic