The asdk.condition.UnaryOr
class is used to add or logic to two UnaryConditions. It provides an implementation of the UnaryCondition interface
that allows for more than one unary condition objects to be combined returning true if any of the unary conditions are true. Similar to the
previous example, a UnaryOr condition could be used to find null or empty collections before processing its elements. The
example below combines the asdk.condition.NotNull
and asdk.condition.PositiveNumber
conditions,
both wrapped within UnaryNot conditions, to determine whether an ArrayList is null or empty, or contains at least one element.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import asdk.*; |
This example is interesting because it demonstrates that arbitrarily complex conditions can be combined to produce sophisticated rules. In the example above both the NotNull and PostiveNumber conditions are passed to UnaryNot conditions that are then encapsulated within a UnaryOr object. This has the effect of returning true when the object passed in is either null or less than one which is a valuable determination often times when processing a collection.