The asdk.condition.UnaryAnd
class is used to add and 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 only if all the unary conditions are true. One common case
for using the UnaryAnd condition is to test whether collection is both non-null and not empty before processing its elements. The
example below combines the asdk.condition.NotNull
and asdk.condition.PositiveNumber
conditions to verify
the contents of an ArrayList using a UnaryAnd object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import asdk.*; |
This example combines the functionality of both NotNull and PositiveNumber to only return true if the value passed to the execute method is both not null and positive. This kind of combination allows for encapsulating the logic of a non-empty collection into a single UnaryAnd object.