Dynamic enum in generated form programmatically

Hi there,

I am trying to generate a dynamic enumeration for a generated form (form fields build by modeler).
There are similar questions in the forum (few years ago): Enum form field dynamically and Load enum form field values dynamically - #2 by StephenOTT but nothing really works.

My approach is a delegate script as following:

public class setEnum implements JavaDelegate {
    private Expression enums;
    private Expression enumVar;

    public void execute(DelegateExecution execution) {
        Map<String, String> values = new LinkedHashMap<String, String>();

        String varName = (String) enumVar.getValue(execution);
        String enumAll = (String) enums.getValue(execution);
        String[] enumPairs = enumAll.split(";");
        for (String enumPair : enumPairs) {
            String[] enumValues = enumPair.split(",");
            values.put(enumValues[0], enumValues[1]);
        }

        EnumFormType formType = new EnumFormType(values);
        execution.setVariable(varName, formType);
    }
}

Field injection like

001,ABC;002,DEF

is transformed to a LinkedHashMap and parsed to the EnumFormType.

But if I use this variable in the modeler as enum type variable the engine throws following error:

org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context: Cannot deserialize object in variable 'AVAILABLE_PRODUCT_TYPES': SPIN/JACKSON-JSON-01006 Cannot deserialize '{"values":...' to java type '[simple type, class org.camunda.bpm.engine.impl.form.type.EnumFormType]'
    org.camunda.bpm.engine.ProcessEngineException: Cannot deserialize object in variable 'AVAILABLE_PRODUCT_TYPES': SPIN/JACKSON-JSON-01006 Cannot deserialize '{"values":...' to java type '[simple type, class org.camunda.bpm.engine.impl.form.type.EnumFormType]'

Does someone know a better approach?
Is there an obvious error in this example which I misunderstood?

Appreciate your help.
Kai