Instance of
Syntax
$object.instanceOf(`$class`)
Description
Checks if object is an instance of class. All subtypes of class are also taken into account. If object should correspond exactly to class without potential subtypes, then $object.type() == `my.module:MyType` can be used (see Object type).
Parameter
| Name | Type | Description | Mandatory | Default |
|---|---|---|---|---|
| object | Business object | An object for which it should be checked whether it belongs to class or one of its subclasses. |
yes | |
| class | string | A class literal describing the class to be checked. | yes |
Return Value
Type: Boolean
Whether object is part of class or one of its subclasses.
Examples
Exact check
{
a = new(`my.module:MyClass`);
$a.instanceOf(`my.module:MyClass`);
}
Output: true
Check for subclasses
{
a = new(`my.module:MyClass`);
$a.instanceOf(`my.module:MySuperClass`);
}
Output: true
a is a subtype of MySuperClass, so the Expression returns true.