OCLOperators create
This page was created by Stephanie on 2025-01-08. Last edited by Wikiadmin on 2026-07-29.
You use create in an OCL expression to create a new instance of a specified class in the current ViewModel or OCL execution scope.
Syntax
<ClassName>.createReplace <ClassName> with the name of the class that you want to instantiate.
Create an object
- Identify the class you need to create.
- Write the class name followed by
.create. - Use the expression where a new instance is required in the current ViewModel or OCL execution scope.
For example, this expression creates a new Customer object:
Customer.createThe result is a brand-new instance of Customer in the current execution scope.
How the syntax works
| Part | Meaning |
|---|---|
Customer
|
The class or type to instantiate. |
.create
|
The OCL operator that creates a new instance of that class. |
Use the class name, not an existing object, before .create. In the example, Customer.create creates a customer instance; it does not act on a customer that already exists.
Related operators
create creates an object instance. If you need a new GUID value for a GUID attribute, use newGuid instead. If you need a collection for iteration, see Sequence or Set.
