if, else

Syntax

if (condition) {
    body
}
or
if (condition) {
    body
}
else {
    body
}

where:

Description

The if/else statement conditionally skip some statements. The condition must evaluate to a boolean value.

Examples

This code will call a rule only if the UML class is abstract :

if (myClass.isAbstract) {
    @abstractClassRule(myClass);
}

This code will call a different rule regarding the number of features of a UML class :

if (myClass.feature.isEmpty()) {
    @emptyFeature(myClass);
}
else {
    @someFeature(myClass);
}