The asdk.condition.InstanceOf
class is used to test whether an object is an instance of a particular type. This
implementation of the UnaryCondition interface, when executed, will determine whether objects passed to the execute method
are an instance of the type that is passed in to the
constructor. This allows for encapsulation of the logic for determining whether objects are actually an instance of
a certain class. The example below demonstrates the use of this class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import asdk.*; |
In this example a HashMap and an ArrayList are created as well as a condition (line 6) that will test whether an object is actually a HashMap. When the condition is executed against the HashMap instance the result is true (lines 8-10), and false is returned when the condition is executed with the arraylist object (lines 12-14).