OCLOperators constraints
(Replacing message template with parser tag)
(Updated Edited template to July 12, 2025.)
Line 24: Line 24:
See also: [[Training:Constraints|Constraints]], [[OCLOperators_brokenConstraints]]  
See also: [[Training:Constraints|Constraints]], [[OCLOperators_brokenConstraints]]  
[[Category:OCL General Operators]]
[[Category:OCL General Operators]]
{{Edited|July|12|2024}}
{{Edited|July|12|2025}}

Revision as of 05:57, 20 January 2025

This page was created by Alexandra on 2017-08-13. Last edited by Stephanie@mdriven.net on 2025-02-10.

This operator returns both meta information about a class's constraints and if it's currently broken.

The return value is a collection of Tuple containing the following:

  1. Name
  2. Description
  3. IsDeleteConstraint: True/False
  4. ErrorLevel: #Information, #Warning or #Error
  5. Broken: Evaluated and Subscribed state of the constraint

Examples

To check if any constraint with error level Error is broken:

self.constraints->select(c|(c.ErrorLevel = #Error) and c.Broken)->isEmpty  -- Returns True if no errors

Returning a collection of Descriptions of broken Warning constraints:

self.constraints->select(c|(c.ErrorLevel = #Warning) and c.Broken)->collect(c|c.Description)

Please Note

This operator earlier resulted in an array of booleans with the constraint result. To get the same functionality now, add .broken=false to the end of the previous expression.

Like this, used with forAll:

self.constraints->forAll(c|c.broken=false)
2021-10-10 10h56 59.gif

See also: Constraints, OCLOperators_brokenConstraints