How can you create a shape with default children and properties

I want a shape to have children and some default properties when it’s created. The end result is hopefully something like this:

Shape {
  ... ...
  businessObject: {
    "$type": "bpmn:UserTask",
    "id": "Activity_019liuk",
    "loopCharacteristics": {
        "$type": "bpmn:MultiInstanceLoopCharacteristics",
        "extensionElements": {
            "$type": "bpmn:ExtensionElements"
        },
        "completionCondition": {
            "$type": "bpmn:Expression",
            "body": "${nrOfCompletedInstances>=1}"
        },
        "isSequential": "false"
    },
    "name": "demo"
  }
  ... ...
}

Currently I’m using the elementFactory.createShape method. But it doesn’t seem to achieve my goal.

In xml, it looks something like this:

<userTask flowable:assignee="${user}" flowable:formFieldValidation="true" flowable:formKey="formkey_9adzx3se92" id="sid-B9554EDF-6D57-42C3-9A74-6CA5206A9FFA" name="1">
   <multiInstanceLoopCharacteristics flowable:collection="${flowableExpressionsService.resolveWorksheetFieldUsersForTaskV2(execution,'update_by', var:get(update_by))}" flowable:elementVariable="user">
     <extensionElements/>
     <completionCondition>${nrOfCompletedInstances&gt;=1}</completionCondition>
   </multiInstanceLoopCharacteristics>
 </userTask>

I hope that when I create <userTask> , <userTask> will have a sublabel <multiInstanceLoopCharacteristics>.

Elements are being created through the elementFactory and bpmnFactory respectively. If you always create elements with a particular extension you’d plug-in that change there. Otherwise you’re free to create any diagram element with a pre-configured business object as you interact with modeling APIs.

So what exactly you need depends on how you’re creating the shape. Could you share an example?