Object creation

Syntax

new(`my.module:MyType`)
new(type: $type, context: $context, transient: false)

Description

Creates a new object of the specified type. As an optional context, another object can be specified in whose logical context the new object will be created. This context object is available when calculating default values of attributes of the newly created object.

Typically, the object in whose composition reference the newly created object will be stored should be passed as the context. When creating a tree structure, the parent node has a composition reference "children", in which a newly created child node will be stored after creation. So when creating the child node, the parent node should be given as a context object.

Parameters

Name Type Description Mandatory Default
type Object type The object type from which a new object is to be created. yes
context Object The object in whose context the creation takes place. Can be used for standard value calculations for attributes. no null
transient Boolean Whether a transient object should be created. Transient objects are only visible locally in the user's session and cannot be stored in the reference of a persistent object. Conversely, however, a transient object can reference normal persistent objects in its references. no false

Return value

type: Subject object

The newly created object of type my.module:MyType.

Examples

new(`my.module:MyClass`)

Output: Creates an object of type my.module:MyClass.