You can use OclCollectiontype in an OCL expression when you need the collection type that corresponds to a model class, for example when working with type information rather than object instances.
Syntax
TypeName.OclCollectiontype.asstring
Return value
OclCollectiontype returns the collection type for the specified class. Use asstring to display that type as text.
| Expression | Result |
|---|---|
Thing.OclCollectiontype.asstring
|
Collection(Thing)
|
Example
Given a model class named Car, use the following expression:
Car.OclCollectiontype.asstring
The expression returns:
Collection(Car)
When to use it
Use this operator when your expression needs information about the collection type of a class. It describes a type; it does not create a collection containing Car objects.
For example, Car.OclCollectiontype.asstring identifies the type as Collection(Car). To construct collections of values in an expression, see Documentation:Collection of strings.
