Summary
Tests whether an expression can be cast into a referenced type. This keyword is used in any expression.
Syntax
[?var:] className (expression instanceof type)
Description
The instanceof operator can be used in the condition part or in the action part of a rule and in a function. It tests whether the passed expression (left operand of instanceof) can be cast into the passed type (right operand of instanceof) without raising a ClassCastException. If it passed successfully, this test returns true. It returns false if the test is unsuccessful.
Example
rule InstanceofTest {
when {
?a: Alarm(equipment instanceof Multiplex);
}
then {
System.out.println("Alarm occurs on Multiplex");
}
};
See Also
as