includesAll lets you test whether one collection contains every element in another collection. Use it in OCL when you need to verify that a required set of values is present in a collection.
Syntax
collection->includesAll(c2)| Part | Meaning |
|---|---|
collection
|
The collection you want to search. |
c2
|
The parameter collection whose elements must all be present in collection.
|
| Result | A Boolean value: true when every element of c2 is contained in collection; otherwise false.
|
Examples
The following expression returns true because both 3 and 4 are present in the sequence:
Sequence{1, 2, 3, 4, 5}->includesAll(Sequence{3, 4})The following expression returns false because 7 is not present in the sequence:
Sequence{1, 2, 3, 4, 5}->includesAll(Sequence{3, 7})Use compatible element types
Use collections with compatible element types. For example, compare integer values with integers, floating-point values with floating-point values, and strings with strings. Mixing incompatible types can cause errors.
includesAll and forAll
Use includesAll to check whether required elements occur in a collection. Use forAll when you need to evaluate a condition for every element instead.
For example, this checks for specific values:
Sequence{1, 2, 3, 4, 5}->includesAll(Sequence{3, 4})A forAll expression checks a condition for each element, rather than checking for the presence of another collection.
