class BPMNFormModelGeneratorImpl implements BPMNFormModelGenerator {

    @Override
    public TaskFormModel generateTaskFormModel(Definitions source,
                                               String taskId,
                                               Path path) {
        Process process = getProcess(source);

        if (process != null) {

            ProcessTaskFormsGenerationResult generationResult = readUserTaskFormVariables(process);

            Optional<TaskFormVariables> resultTaskFormVariables = Optional.ofNullable(generationResult.getTaskFormVariablesByTaskId(taskId));

            if (resultTaskFormVariables.isPresent()) {
                TaskFormVariables formVariables = resultTaskFormVariables.get();

                if (!formVariables.isValid()) {
                    throw new IllegalStateException(generateErrorMessage(formVariables));
                }

                final ClassLoader projectClassLoader = projectClassLoaderHelper.getModuleClassLoader(moduleService.resolveModule(path));

                return formVariables.toFormModel(variable -> createModelProperty(variable, projectClassLoader));
            }
        }
        return null;
    }

    @Inject public  BPMNFormModelGeneratorImpl(KieModuleService moduleService,
                                      ModuleClassLoaderHelper projectClassLoaderHelper);

}