Expressions

Here is the list of available MQL expressions:

Literals Strings: "Hello World"
Booleans: true or false
Numbers: 3, 0.08
Lists: ["winter", "spring", "summer", "autumn"]
Maps: {"winter" = "cold", "summer" = "warm"}
No value: null
Variables myClass
Dotted notation myClass.isAbstract(), myClass.namespace.name
Concatenation "Hello" + "World"
Arithmetical operations a + b, a * b
Comparison operations name == "Account", size > 2
Logical operations ! isAbstract, a || b
Type checking myClassifier instanceof uml21.Actor
Range access myString[0], myList[1..4]
Default value expression myProperty.type.name ? "String"
Transient links myClass#targets.iterator()
Static field or method access System.getProperty("myProperty")
Constructor call java.util.Properties.new()

Parentheses

Parentheses can be used to group expressions: (a + b) * (2 - c)

Operator precedence

The following table shows the precedence assigned to the operators. The operators in this table are listed in precedence order: the higher in the table an operator appears, the higher its precedence. Operators with higher precedence are evaluated before operators with a relatively lower precedence. Operators on the same line have equal precedence. When binary operators (operators with two parameters, as + and -) of equal precedence appear next to each other, they are evaluated in left-to-right order.

postfix operators [subStringRange] . (methodParameters)
unary operators +expr -expr !
multiplicative * / %
additive + -
relational < > <= >=
equality == !=
logical AND &&
logical OR ||
numerical range ..

Note that the precedence rules are the same as in Java, C or JavaScript, except that MQL has some operators that do not exist in those languages.