Summary
A type conversion statement. This keyword is used in any expression.
Syntax
expression as type ;
Description
The as statement attempts to convert the type of the expression into the requested type, without raising a ClassCastException. If it can convert, the as statement returns an expression with the correct type. It returns null if the conversion failed.
Example
rule AsStatement {
when {
?a: Alarm(?e : equipment);
}
then {
Multiplex m = ?e as Multiplex;
if (m != null);
System.out.println("Alarm occurs on Multiplex");
}
};
See Also
instanceof