(Automatically adding template at the end of the page.) |
No edit summary |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
<message>Write the content here to display this box</message> | |||
You can edit enumerations by right-clicking on any model element in the "model content" window. | You can edit enumerations by right-clicking on any model element in the "model content" window. | ||
[[File:Edit enumerations menu.png|none|thumb|469x469px]] | [[File:Edit enumerations menu.png|none|thumb|469x469px]] | ||
Line 5: | Line 6: | ||
The defined enumeration is a class in the model's type system. | The defined enumeration is a class in the model's type system. | ||
For example, you can return a list of the values. This returns a collection of ImportColumn [[Tuple]]<nowiki/>s. | For example, you can return a list of the values. This returns a collection of ImportColumn [[Documentation:Tuple|Tuple]]<nowiki/>s. | ||
ImportColumn.allInstances | ImportColumn.allInstances | ||
Convert this to a list of strings for each Enum value (for example to be used in a list on screen): | Convert this to a list of strings for each Enum value (for example to be used in a list on screen): | ||
Line 13: | Line 14: | ||
ImportColumn.allInstances->select(ic|ic = #JournalName).asString | ImportColumn.allInstances->select(ic|ic = #JournalName).asString | ||
===== Get the value of an Enum [[tuple]]: ===== | ===== Get the value of an Enum [[Documentation:Tuple|tuple]]: ===== | ||
(#JournalName).toString | (#JournalName).toString | ||
('''note: asString''' does not work on Enum tuples) | ('''note: asString''' does not work on Enum tuples) | ||
===== Checking if a collection includes a value ===== | ===== Checking if a collection includes a value ===== | ||
You can't use the [[OCLOperators includes|includes]] operator on collections of Enum. You have to select the value and check if you get a "hit". | You can't use the [[Documentation:OCLOperators includes|includes]] operator on collections of Enum. You have to select the value and check if you get a "hit". | ||
This works: | This works: | ||
SysSingleton.SO.ActiveUser.UserModes->select(x|x = #Consultant)->notEmpty | SysSingleton.SO.ActiveUser.UserModes->select(x|x = #Consultant)->notEmpty | ||
'''''This does not work'':''' SysSingleton.SO.ActiveUser.UserModes->includes(#Consultant) | '''''This does not work'':''' SysSingleton.SO.ActiveUser.UserModes->includes(#Consultant) | ||
===== Checking the ordinal number of a enum value ===== | |||
MyEnum.allinstances.Indexof(someObject.SomeEnumProp) | |||
[[Category:MDriven Designer]] | [[Category:MDriven Designer]] | ||
[[Category:OCL]] | [[Category:OCL]] | ||
{{Edited|July|12| | {{Edited|July|12|2025}} |
Latest revision as of 05:50, 11 February 2025
You can edit enumerations by right-clicking on any model element in the "model content" window.
The enumeration editing window:
The defined enumeration is a class in the model's type system.
For example, you can return a list of the values. This returns a collection of ImportColumn Tuples.
ImportColumn.allInstances
Convert this to a list of strings for each Enum value (for example to be used in a list on screen):
ImportColumn.allInstances.asString
Select an Enum value from the list, then get the string value from that:
ImportColumn.allInstances->select(ic|ic = #JournalName).asString
Get the value of an Enum tuple:
(#JournalName).toString
(note: asString does not work on Enum tuples)
Checking if a collection includes a value
You can't use the includes operator on collections of Enum. You have to select the value and check if you get a "hit".
This works:
SysSingleton.SO.ActiveUser.UserModes->select(x|x = #Consultant)->notEmpty
This does not work: SysSingleton.SO.ActiveUser.UserModes->includes(#Consultant)
Checking the ordinal number of a enum value
MyEnum.allinstances.Indexof(someObject.SomeEnumProp)