OCLOperators
No edit summary |
|||
(13 intermediate revisions by 3 users not shown) | |||
Line 10: | Line 10: | ||
|All the objects of the class | |All the objects of the class | ||
|- | |- | ||
|'''allinstancesAtTime''' | |'''[[OCLOperators allInstancesAtTime|allinstancesAtTime]]''' | ||
|All the currently loaded instances | |All the currently loaded instances | ||
|- | |- | ||
|'''[[OCLOperators allStates| | |'''[[OCLOperators allStates|allStates]]''' | ||
|Meta information about available states in state machines the class may contain | |Meta information about available states in state machines the class may contain | ||
|- | |- | ||
|'''allSubClasses''' | |'''[[OCLOperators allSubClasses|allSubClasses]]''' | ||
|Meta information on all the sub classes this class has | |Meta information on all the sub classes this class has | ||
|- | |- | ||
|''' | |'''[[OCLOperators allSuperTypes|allSuperTypes]]''' | ||
|Meta information on all the super classes – in inheritance order the class has | |Meta information on all the super classes – in inheritance order the class has | ||
|- | |- | ||
|'''associationEnds''' | |'''[[OCLOperators associationEnds|associationEnds]]''' | ||
|Meta information on all the associationEnds | |Meta information on all the associationEnds | ||
|- | |- | ||
|'''Asstring''' | |'''[[OCLOperators asString|Asstring]]''' | ||
|The string representation of the class – the asString operation is available on everything | |The string representation of the class – the asString operation is available on everything | ||
|- | |- | ||
|'''Attributes''' | |'''[[OCLOperators attributes|Attributes]]''' | ||
|Meta information about what attributes the class has | |Meta information about what attributes the class has | ||
|- | |- | ||
|'''Contraints''' | |'''[[OCLOperators constraints|Contraints]]''' | ||
|Meta information on what constraints the class has | |Meta information on what constraints the class has | ||
|- | |- | ||
|''' | |'''[[OCLOperators emptyList|emptylist]]''' | ||
|Returns an empty list typed to hold objects of the class | |Returns an empty list typed to hold objects of the class | ||
|- | |- | ||
|''' | |'''isDirtyMember''' | ||
| | | | ||
|- | |- | ||
Line 43: | Line 43: | ||
| | | | ||
|- | |- | ||
|'''nullValue''' | |'''[[OCLOperators nullValue|nullValue]]''' | ||
|A typed null value | |A typed null value | ||
|- | |- | ||
|'''objectFromExternalId''' | |'''[[OCLOperators objectfromExternalId|objectFromExternalId]]''' | ||
|An external identity will be resolved to the object | |An external identity will be resolved to the object | ||
|- | |- | ||
|'''oclAsType''' | |'''[[OCLOperators oclAsType|oclAsType]]''' | ||
|The type of the class | |The type of the class | ||
|- | |- | ||
|'''oclIsKindOf''' | |'''[[OCLOperators oclIsKindOf|oclIsKindOf]]''' | ||
|This is to if a class is a subclass or a the class itself and not unrelated | |This is to if a class is a subclass or a the class itself and not unrelated | ||
|- | |- | ||
|'''oclIsTypeOf''' | |'''[[OCLOperators oclIsTypeOf|oclIsTypeOf]]''' | ||
|Returns true if | |Returns true if | ||
|- | |- | ||
|'''oclSingleton''' | |'''[[OCLOperators oclSingleton|oclSingleton]]''' | ||
|Classes that implements the Singleton pattern – by setting IsSingleton=true – will return the singleton instance with this operator | |Classes that implements the Singleton pattern – by setting IsSingleton=true – will return the singleton instance with this operator | ||
|- | |- | ||
Line 67: | Line 67: | ||
| | | | ||
|- | |- | ||
|''' | |'''superTypes''' | ||
| | | | ||
|- | |- | ||
|'''TaggedValue''' | |'''[[OCLOperators taggedValue|TaggedValue]]''' | ||
|Meta information on tagged values set in the class | |Meta information on tagged values set in the class | ||
|- | |- | ||
|'''TaggedValueOnFeature''' | |'''[[OCLOperators taggedValueOnFeature|TaggedValueOnFeature]]''' | ||
|Meta information on Tagged values set on a named feature in the class | |Meta information on Tagged values set on a named feature in the class | ||
|- | |- | ||
|'''Typename''' | |'''[[OCLOperators typename|Typename]]''' | ||
|The type name as a string | |The type name as a string | ||
|- | |- | ||
|'''ViewModels''' | |'''[[OCLOperators ViewModels|ViewModels]]''' | ||
|A tuple with the ViewModels for this class a members | |A tuple with the ViewModels for this class a members | ||
|} | |} | ||
== Collection operators == | == Collection operators == | ||
Once you have a collection of objects there are certain operators that are applicable to it. Again you can use the OCL-Editor to see what they are: | Once you have a collection of objects there are certain operators that are applicable to it. | ||
See this page for [[examples on collection operators]] | |||
Again you can use the OCL-Editor to see what they are: | |||
[[File:Collection of objects operators.png|frameless|453x453px|link=https://wiki.mdriven.net/index.php/File:Collection_of_objects_operators.png]] | [[File:Collection of objects operators.png|frameless|453x453px|link=https://wiki.mdriven.net/index.php/File:Collection_of_objects_operators.png]] | ||
Line 91: | Line 95: | ||
!Description | !Description | ||
|- | |- | ||
|'''->append''' | |'''[[OCLOperators any|->any]]''' | ||
|Returns any element contained in ''self'' that validates the condition ''expr'', null otherwise. | |||
|- | |||
|'''[[OCLOperators append|->append]]''' | |||
|Add another object last | |Add another object last | ||
|- | |- | ||
|'''->asBag''' | |'''[[OCLOperators asBag|->asBag]]''' | ||
|Collapses to one list | |Collapses to one list | ||
|- | |- | ||
|'''->asSequence''' | |'''[[OCLOperators asSequence|->asSequence]]''' | ||
|Collapses to one list | |Collapses to one list | ||
|- | |- | ||
|'''-> | |'''[[OCLOperators asSet|->asSet]]''' | ||
|Remove doublets | |Remove doublets | ||
|- | |- | ||
|'''->at''' | |'''[[OCLOperators at|->at]]''' | ||
|Get the objects at X where the first index is 1 | |Get the objects at X where the first index is 1 | ||
|- | |- | ||
|'''->at0''' | |'''[[OCLOperators at0|->at0]]''' | ||
|Get the objects at X where the first index is 0 | |Get the objects at X where the first index is 0 | ||
|- | |- | ||
|'''->collect''' | |'''[[OCLOperators collect|->collect]]''' | ||
|Iterate over the collection and build a tuple result | |Iterate over the collection and build a tuple result | ||
|- | |- | ||
|'''->count''' | |'''[[OCLOperators count|->count]]''' | ||
|Count how many meet a certain criteria | |Count how many meet a certain criteria | ||
|- | |- | ||
|'''->difference''' | |[[OCLOperators dictionary|'''->dictionary''']] | ||
|Efficiently looks up values | |||
|- | |||
|'''[[OCLOperators difference|->difference]]''' | |||
|The difference between 2 collections | |The difference between 2 collections | ||
|- | |- | ||
|'''->excluding''' | |'''[[OCLOperators excluding|->excluding]]''' | ||
|The collection except this single object | |The collection except this single object | ||
|- | |- | ||
|'''->exists''' | |'''[[OCLOperators exists|->exists]]''' | ||
|Are there any objects that fulfill the criteria | |Are there any objects that fulfill the criteria | ||
|- | |- | ||
|'''->filterOnType''' | |'''[[OCLOperators filterOnType|->filterOnType]]''' | ||
|Only keep the ones of a certain type | |Only keep the ones of a certain type | ||
|- | |- | ||
|'''->first''' | |'''[[OCLOperators first|->first]]''' | ||
|Return the first object | |Return the first object | ||
|- | |- | ||
|'''->forAll''' | |'''[[OCLOperators forAll|->forAll]]''' | ||
|Iterate all that fulfills the critera | |Iterate all that fulfills the critera | ||
|- | |- | ||
|'''->groupBy''' | |'''[[OCLOperators groupBy|->groupBy]]''' | ||
|Build collection of tuples grouped by some aspect | |Build collection of tuples grouped by some aspect | ||
|- | |- | ||
|'''->includes''' | |'''[[OCLOperators includes|->includes]]''' | ||
|Does the collection include the object | |Does the collection include the object | ||
|- | |- | ||
|'''->includesAll''' | |'''[[OCLOperators includesAll|->includesAll]]''' | ||
|Does the collection include the whole other collection | |Does the collection include the whole other collection | ||
|- | |- | ||
|'''->including''' | |'''[[OCLOperators including|->including]]''' | ||
| | |Returns the list with the element in the parameter included. | ||
|- | |- | ||
|'''->IndexOf''' | |'''[[OCLOperators indexOf|->IndexOf]]''' | ||
|The 1 based index of an object in the collection possibly -1 if not existing | |The 1 based index of an object in the collection possibly -1 if not existing | ||
|- | |- | ||
|'''->indexOf0''' | |'''[[OCLOperators indexOf0|->indexOf0]]''' | ||
|The 0 based index of an object in the collection possibly -1 if not existing | |The 0 based index of an object in the collection possibly -1 if not existing | ||
|- | |- | ||
|'''->intersection''' | |'''[[OCLOperators intersection|->intersection]]''' | ||
|The intersection of two collections | |The intersection of two collections | ||
|- | |- | ||
|'''->isEmpty''' | |'''[[OCLOperators isEmpty|->isEmpty]]''' | ||
|Returns true if the collection is empty | |Returns true if the collection is empty | ||
|- | |- | ||
|'''->last''' | |'''[[OCLOperators last|->last]]''' | ||
|Returns the last object in the collection | |Returns the last object in the collection | ||
|- | |- | ||
|'''->notEmpty''' | |'''[[OCLOperators notEmpty|->notEmpty]]''' | ||
|Returns true of the collection is not empty | |Returns true of the collection is not empty | ||
|- | |- | ||
|'''->orderBy''' | |'''[[OCLOperators orderBy|->orderBy]]''' | ||
|Sorts the collection on one or more properties | |Sorts the collection on one or more properties | ||
|- | |- | ||
|'''->orderDescending''' | |'''[[OCLOperators orderDescending|->orderDescending]]''' | ||
|Sort the from biggest to smallest | |Sort the from biggest to smallest | ||
|- | |- | ||
|'''->orderGeneric''' | |'''[[OCLOperators orderGeneric|->orderGeneric]]''' | ||
|Sorts the list of properties with interchangeable sort order: (expr1, OclSortDirection::ascending, expr2, OclSortDirection::descending...) | |Sorts the list of properties with interchangeable sort order: (expr1, OclSortDirection::ascending, expr2, OclSortDirection::descending...) | ||
|- | |- | ||
|'''->prepend''' | |'''[[OCLOperators prepend|->prepend]]''' | ||
|Add an object in front of the list | |Add an object in front of the list | ||
|- | |- | ||
|'''->reject''' | |'''[[OCLOperators reject|->reject]]''' | ||
|Returns the objects not matching the criteria | |Returns the objects not matching the criteria | ||
|- | |- | ||
|'''->select''' | |'''[[OCLOperators select|->select]]''' | ||
|Returns the objects matching the criteria | |Returns the objects matching the criteria | ||
|- | |- | ||
|'''->size''' | |'''[[OCLOperators size|->size]]''' | ||
|Returns the number of elements in the collection | |Returns the number of elements in the collection | ||
|- | |- | ||
|'''->subsequence''' | |'''[[OCLOperators subSequence|->subsequence]]''' | ||
|Returns a smaller collection from a start to stop | |Returns a smaller collection from a start to stop | ||
|- | |- | ||
|'''->symmetricDifference''' | |'''[[OCLOperators symmetricDifference|->symmetricDifference]]''' | ||
|The symmetric difference between the collections; ie all the objects in collection1 or collection2 but not in both | |The symmetric difference between the collections; ie all the objects in collection1 or collection2 but not in both | ||
|- | |- | ||
|'''->union''' | |'''[[OCLOperators union|->union]]''' | ||
|The set of objects in collection1 and objects in collection2 | |The set of objects in collection1 and objects in collection2 | ||
|} | |} | ||
== String operators == | |||
{| class="wikitable" | |||
!Operators | |||
!Description | |||
|- | |||
|[[Escape codes]] | |||
|Escape (special) characters used in OCL | |||
|- | |||
| | |||
| | |||
|- | |||
| | |||
| | |||
|} | |||
== Viewmodel operators (on selfVM variable) == | |||
See page [[SelfVM]] | |||
[[Category:OCL]] | |||
[[Category:Beginner]] | |||
[[Category:OCLOperators]] |
Revision as of 20:37, 9 December 2018
General operators
To find all available you can open the OCL-Editor and type in a class:
Operators | Description |
---|---|
Allinstances | All the objects of the class |
allinstancesAtTime | All the currently loaded instances |
allStates | Meta information about available states in state machines the class may contain |
allSubClasses | Meta information on all the sub classes this class has |
allSuperTypes | Meta information on all the super classes – in inheritance order the class has |
associationEnds | Meta information on all the associationEnds |
Asstring | The string representation of the class – the asString operation is available on everything |
Attributes | Meta information about what attributes the class has |
Contraints | Meta information on what constraints the class has |
emptylist | Returns an empty list typed to hold objects of the class |
isDirtyMember | |
isNull | |
nullValue | A typed null value |
objectFromExternalId | An external identity will be resolved to the object |
oclAsType | The type of the class |
oclIsKindOf | This is to if a class is a subclass or a the class itself and not unrelated |
oclIsTypeOf | Returns true if |
oclSingleton | Classes that implements the Singleton pattern – by setting IsSingleton=true – will return the singleton instance with this operator |
OclType | |
safeCast | |
superTypes | |
TaggedValue | Meta information on tagged values set in the class |
TaggedValueOnFeature | Meta information on Tagged values set on a named feature in the class |
Typename | The type name as a string |
ViewModels | A tuple with the ViewModels for this class a members |
Collection operators
Once you have a collection of objects there are certain operators that are applicable to it.
See this page for examples on collection operators
Again you can use the OCL-Editor to see what they are:
Operators | Description |
---|---|
->any | Returns any element contained in self that validates the condition expr, null otherwise. |
->append | Add another object last |
->asBag | Collapses to one list |
->asSequence | Collapses to one list |
->asSet | Remove doublets |
->at | Get the objects at X where the first index is 1 |
->at0 | Get the objects at X where the first index is 0 |
->collect | Iterate over the collection and build a tuple result |
->count | Count how many meet a certain criteria |
->dictionary | Efficiently looks up values |
->difference | The difference between 2 collections |
->excluding | The collection except this single object |
->exists | Are there any objects that fulfill the criteria |
->filterOnType | Only keep the ones of a certain type |
->first | Return the first object |
->forAll | Iterate all that fulfills the critera |
->groupBy | Build collection of tuples grouped by some aspect |
->includes | Does the collection include the object |
->includesAll | Does the collection include the whole other collection |
->including | Returns the list with the element in the parameter included. |
->IndexOf | The 1 based index of an object in the collection possibly -1 if not existing |
->indexOf0 | The 0 based index of an object in the collection possibly -1 if not existing |
->intersection | The intersection of two collections |
->isEmpty | Returns true if the collection is empty |
->last | Returns the last object in the collection |
->notEmpty | Returns true of the collection is not empty |
->orderBy | Sorts the collection on one or more properties |
->orderDescending | Sort the from biggest to smallest |
->orderGeneric | Sorts the list of properties with interchangeable sort order: (expr1, OclSortDirection::ascending, expr2, OclSortDirection::descending...) |
->prepend | Add an object in front of the list |
->reject | Returns the objects not matching the criteria |
->select | Returns the objects matching the criteria |
->size | Returns the number of elements in the collection |
->subsequence | Returns a smaller collection from a start to stop |
->symmetricDifference | The symmetric difference between the collections; ie all the objects in collection1 or collection2 but not in both |
->union | The set of objects in collection1 and objects in collection2 |
String operators
Operators | Description |
---|---|
Escape codes | Escape (special) characters used in OCL |
Viewmodel operators (on selfVM variable)
See page SelfVM
This page was edited 106 days ago on 01/11/2024. What links here