CDL Operators
Operators are predefined tokens consisting of Unicode characters to be used as the expression operators among the expression operands. An operator specifies the operation to be performed at run time between the operands.
This section includes the following:
-
Operators Supported By CDL
-
Operator Results
-
Operator Precedence
-
LIKE and NOT LIKE Operators
-
Text Concatenation Operator
-
COLLECT Operator
Operators Supported By CDL
The following table lists the predefined operators supported by CDL.
Operator Type |
Operators |
Description |
---|---|---|
Logical |
AND |
AND requires two operands and returns true if both are true. |
Logical |
OR |
OR requires two operands and returns true if either is true. |
Logical |
NOT |
NOT requires one operand and returns its opposite value: false if the operand is true, true if the operand is false. |
Logical |
REQUIRES |
REQUIRES requires two operands. |
Logical |
IMPLIES |
IMPLIES requires two operands. or details. |
Logical |
EXCLUDES |
EXCLUDES requires two operands. |
Logical |
NEGATES |
NEGATES requires two operands. |
Logical and Comparison |
LIKE |
LIKE requires two text literal operands and returns true if they match. See LIKE and NOT LIKE Operators for restrictions. |
Logical and Comparison |
NOT LIKE |
LIKE requires two text literal operands and returns true if they match. See LIKE and NOT LIKE Operators for restrictions. |
Logical, Arithmetic, and Comparison |
= |
Equals requires two operands and returns true if both are the same. |
Logical, Arithmetic, and Comparison |
> |
Greater than requires two operands and returns true if the first is greater than the second. |
Logical, Arithmetic, and Comparison |
< |
Less than requires two operands and returns true if the first is less than the second. |
Logical, Arithmetic, and Comparison |
<> |
Not equal requires two operands and returns true if they're different. |
Logical, Arithmetic, and Comparison |
<= |
Less than or equal to requires two operands and returns true if the first operand is less than or equal to the second. |
Logical, Arithmetic, and Comparison |
>= |
Greater than or equal requires two operands and returns "true" if the first operand is greater than or equal to the second. |
Arithmetic |
* |
Performs arithmetic multiplication on numeric operands. |
Arithmetic |
/ |
Performs arithmetic division on numeric operands. |
Arithmetic |
- |
Performs arithmetic subtraction on numeric operands. |
Arithmetic |
+ |
Performs arithmetic addition on numeric operands. |
Arithmetic |
^ |
Performs arithmetic exponential on numeric operands. |
Arithmetic |
% |
Performs arithmetic modulo on numeric operands. |
Text |
+ |
Performs a concatenation of text strings. See Text Concatenation Operator for restrictions. |
Other |
Assign(node) |
Used only in Defaults and Search Decisions to force a node to be bound at a particular point in the specified sequence. If the Domain Ordering setting is specified in the node's details page, binding happens according to this setting. Otherwise, the constraint engine's implicit binding method for this operator type is used. |
Other |
IncMin() |
Used only in Defaults and Search Decisions. Similar to ASSIGN, but this operator overrides any explicit or implicit domain ordering method for binding the node and attempts a binding using a binary search with increasing minimum. This operator is valid for integers and decimals, including items and options with quantity. Applies to the node's default system attribute when a system attribute isn't explicitly referenced (for example, State, Quantity, or Value). When used with items, you can specify the RelativeQuantity attribute as an alternative. |
Other |
( ) , . - |
Parentheses ( ) are used to group sub-expressions. Comma (,) is used to separate function arguments. Dot (.) is used for referencing objects in the Model tree structure. Unary minus (-) is used to make positive values negative and negative values positive. |
Operator Results
The result of each expression operator can participate as an operand of another operator as long as the return type of the former matches with the argument type of the latter.
The following table lists the basic return data types of each type of operator.
Mapping of Operators and Data Types
Operators |
Data Type |
---|---|
Arithmetic |
INTEGER DECIMAL |
Logical |
BOOLEAN |
Comparison |
BOOLEAN |
Operator Precedence
Operators are processed in the order given in the following table. Operators with equal precedence are evaluated left to right.
The following table lists the precedence of expression operators in CDL. The columns are Operator, Precedence (direction), and Description.
Precedence of Operators
Operator |
Precedence (direction) |
Description |
---|---|---|
|
1 (right) |
Parenthesis |
|
2 (right) |
Navigation |
|
3 (right) |
Arithmetic power |
Unary |
4 |
Unary plus and minus, Not |
|
5 (left) |
Arithmetic multiplication and division |
Binary |
6 (left) |
Arithmetic plus and minus, text concatenation |
|
7 (left) |
Comparison operators |
|
8 (left) |
Logical AND |
|
9 (left) |
Logical OR |
|
10 (left) |
Logic operators |
LIKE and NOT LIKE Operators
Although LIKE and NOT LIKE are included as text relational operators, they can only be used in static context; for example, the WHERE clause of iterators. As with any TEXT data type, you can't use LIKE and NOT LIKE with run time participants unless it evaluates to a constant string. Configurator validates this condition when you compile the model.
LIKE Expression Resulting in a BOOLEAN Value
a.attr.Value() LIKE "%eig%"
A TRUE result is returned if the text of a.attr contains the characters 'eig', such as a.attr ='weight' or 'eight'. FALSE is returned if the text of a.attr='rein'. .
In the following example, selecting option A and B implies that options within C are selected when the value of their associated user-defined attribute is "A1B1".
Constrain Alltrue('A','B') implies &C
for all &C in {optionsof('C')}
where &C.userAttrs["Selections.AB Compatibility"] like "A1B1"
In the example below, selecting option A and B implies that options within C are selected when the value of their associated user-defined attribute is something other than "A1B1".
Constrain Alltrue('A','B') implies &C
for all &C in {optionsof('C')}
where not (&C.userAttrs["Selections.AB Compatibility"] like "A1B1" )
For a list of comparison operators, see Operators Supported By CDL.
Text Concatenation Operator
Although +
is included
as a text concatenation operator, it can only be used in static context;
for example, the WHERE clause of iterators. As with any TEXT data
type, you can't use text concatenation in the actual body of a constrain
or contributor statement unless it evaluates to a constant string.
Configurator validates this condition when you compile
the model.
COLLECT Operator
The COLLECT keyword is used to build a collection and provide it to an operator that takes a collection as an argument. For example, instead of AnyTrue(x, y, z) you can write AnyTrue(COLLECT &c FOR ALL &c IN {x,y,z}).