OCLOperators constraints
No edit summary
Line 9: Line 9:


===== Examples =====
===== Examples =====
To check if any constraint with error level '''Error''' is broken;
To check if any constraint with error level '''Error''' is broken;  
self.constraints->select(c|c.ErrorLevel = #Error)->forAll(c|c.Broken)
  self.constraints->select(c|(c.ErrorLevel = #Error) and c.Broken)->isEmpty  -- Returns True if no errors
The same thing, differently expressed;
  self.constraints->select(c|(c.ErrorLevel = #Error) and c.Broken)->notEmpty
Returning a collection of Descriptions of broken Warning constraints;
Returning a collection of Descriptions of broken Warning constraints;
  self.constraints->select(c|(c.ErrorLevel = #Warning) and c.Broken)->collect(c|c.Description)
  self.constraints->select(c|(c.ErrorLevel = #Warning) and c.Broken)->collect(c|c.Description)
Line 21: Line 19:
Like this;
Like this;
  self.constraints.name
  self.constraints.name
[[Category:OCLOperators]]
  [[Category:OCLOperators]]

Revision as of 14:19, 14 December 2018

The operator return 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 a array of constraint names. To get the same functionality now, add .name to the end of the previous expression.

Like this;

self.constraints.name
This page was edited 101 days ago on 02/10/2024. What links here