OCLOperators constraints
(Automatically adding template at the end of the page.) |
(Replacing message template with parser tag) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<message>Write the content here to display this box</message> | |||
This operator returns both meta information about a class's constraints and if it's currently broken. | This operator returns both meta information about a class's constraints and if it's currently broken. | ||
Line 8: | Line 9: | ||
# Broken: Evaluated and [[Subscribed]] state of the constraint | # Broken: Evaluated and [[Subscribed]] state of the constraint | ||
=== 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) and c.Broken)->isEmpty -- Returns True if no errors | self.constraints->select(c|(c.ErrorLevel = #Error) and c.Broken)->isEmpty -- Returns True if no errors | ||
Line 14: | Line 15: | ||
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) | ||
=== '''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. | 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. | ||
Line 21: | Line 22: | ||
[[File:2021-10-10 10h56 59.gif|none|thumb|573x573px]] | [[File:2021-10-10 10h56 59.gif|none|thumb|573x573px]] | ||
See also: [[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|2024}} |
Latest revision as of 07:50, 17 June 2024
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:
- Name
- Description
- IsDeleteConstraint: True/False
- ErrorLevel: #Information, #Warning or #Error
- 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)
See also: Constraints, OCLOperators_brokenConstraints
This page was edited 94 days ago on 06/17/2024. What links here