OCLOperators
No edit summary
Line 84: Line 84:


== 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]]

Revision as of 15:39, 13 August 2017

General operators

To find all available you can open the OCL-Editor and type in a class:

Ocl-editor 1.png

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:

Collection of objects operators.png

Operators Description
->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
->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
->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
This page was edited 77 days ago on 01/11/2024. What links here