OCLOperators allInstances
No edit summary
No edit summary
 
(14 intermediate revisions by 6 users not shown)
Line 1: Line 1:
It is a common operator. To find all available you can open the OCL-Editor and type in a class:
<message>Write the content here to display this box</message>
=== allInstances () : Set{T} ===
Returns a Set containing all of the existing instances of the current classifier (along with instances of all its inherited classifiers).
{| class="wikitable"
!Expression
!Result
|-
|Thing.allInstances
|all the Thing object instances currently in your system - if only in DB objects will be loaded
|}
Your model is central to all expressions you will handle. We will use this model for the examples:


Your model is central to all expression you will handle. We will use this model to for the examples:
[[File:Allinstances operator.png|frameless|422x422px]]
 
[[File:Allinstances operator.png|frameless|355x355px]]
{| class="wikitable"
{| class="wikitable"
!Operators
!Operators
Line 9: Line 17:
|-
|-
|'''Thing.allinstances'''
|'''Thing.allinstances'''
|Gives you a list of all Things
|Gives you a list of all things
|-
|-
|'''Things.allinstances->select(someInt>3)'''
|'''Things.allinstances->select(someInt>3)'''
Line 21: Line 29:
|-
|-
|'''Things.allinstances.Details'''
|'''Things.allinstances.Details'''
|Gives a list of all detail objects that are connected to a Thing. The Detail objects that float around without a Thing will not be in the list
|Gives a list of all Detail objects that are connected to a Thing. The Detail objects that float around without a Thing will not be on the list
|-
|-
|'''Things.allinstances.Details.Attribute1'''
|'''Things.allinstances.Details.Attribute1'''
|A list of nullable strings from the contents from the details attribute1. Note that OCL is null-tolerant – you do not need to check if the Details exists of not – the language handles null checks for you
|A list of nullable strings from the contents of the details attribute1. Note that OCL is null-tolerant – you do not need to check if the Details exist or not – the language handles null checks for you.
|-
|-
|'''SubClassThing1.allinstances.Details'''
|'''SubClassThing1.allinstances.Details'''
Line 32: Line 40:
|Filtering on Specialization is done with an operator SafeCast. This is null safe so for all objects that do not fit the profile the expression returns false
|Filtering on Specialization is done with an operator SafeCast. This is null safe so for all objects that do not fit the profile the expression returns false
|}
|}
This was a description of the <code><span class="col-black">'''allinstances'''</span></code> operator. It is a common operator. To find all available operators, you can open the OCL Editor and type in a class.
'''See:''' [[Documentation:OCLOperators|OCLOperators]]
[[Category:OCL General Operators]]
{{Edited|July|12|2025}}

Latest revision as of 05:31, 18 March 2025

This page was created by Alexandra on 2017-08-08. Last edited by Stephanie@mdriven.net on 2025-03-18.

allInstances () : Set{T}

Returns a Set containing all of the existing instances of the current classifier (along with instances of all its inherited classifiers).

Expression Result
Thing.allInstances all the Thing object instances currently in your system - if only in DB objects will be loaded

Your model is central to all expressions you will handle. We will use this model for the examples:

Allinstances operator.png

Operators Description
Thing.allinstances Gives you a list of all things
Things.allinstances->select(someInt>3) Only things with someInt bigger than 3
Thing.allinstances->select( (someInt>3) and (someInt<6)) Only things with someInt bigger than 3 but less than 6. Notice the extra parenthesis to or the Boolean expressions together
Things.allinstances->select(x|x.someInt>3) Here we introduce the loop variable x. We separate the definition of x from the usage of x with the pipe sign “|”. Loop variables are optional but if names are unique – but you will need to use them to give precision or to if you want to perform operations on the loop context itself.
Things.allinstances.Details Gives a list of all Detail objects that are connected to a Thing. The Detail objects that float around without a Thing will not be on the list
Things.allinstances.Details.Attribute1 A list of nullable strings from the contents of the details attribute1. Note that OCL is null-tolerant – you do not need to check if the Details exist or not – the language handles null checks for you.
SubClassThing1.allinstances.Details Inherited features of classes are directly accessible
Thing.allInstances- >select(x|x.safeCast(SubClassThing1). OnlyAvailableInSubClass='Hello') Filtering on Specialization is done with an operator SafeCast. This is null safe so for all objects that do not fit the profile the expression returns false

This was a description of the allinstances operator. It is a common operator. To find all available operators, you can open the OCL Editor and type in a class.

See: OCLOperators