🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators OclCollectionType
This page was created by Stephanie on 2025-01-08. Last edited by Wikiadmin on 2026-07-29.

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.

See also