use of ilargia.entitas.codeGeneration.data.CodeGeneratorData in project Entitas-Java by Rubentxu.
the class CodeGenerator method generate.
List<CodeGenFile> generate(String messagePrefix, List<ICodeGeneratorDataProvider> dataProviders, List<ICodeGenerator> codeGenerators, List<ICodeGenFilePostProcessor> postProcessors) {
_cancel = false;
List<CodeGeneratorData> data = new ArrayList<>();
int total = dataProviders.size() + codeGenerators.size() + postProcessors.size();
int progress = 0;
for (ICodeGeneratorDataProvider dataProvider : dataProviders) {
if (_cancel) {
return new ArrayList<>();
}
progress += 1;
if (OnProgress != null) {
OnProgress.exec(messagePrefix + "Creating model", dataProvider.getName(), (float) progress / total);
}
data.addAll(dataProvider.getData());
}
List<CodeGenFile> files = new ArrayList<>();
for (ICodeGenerator generator : codeGenerators) {
if (_cancel) {
return new ArrayList<>();
}
progress += 1;
if (OnProgress != null) {
OnProgress.exec(messagePrefix + "Creating files", generator.getName(), (float) progress / total);
}
files.addAll(generator.generate(data));
}
for (ICodeGenFilePostProcessor postProcessor : postProcessors) {
if (_cancel) {
return new ArrayList<>();
}
progress += 1;
if (OnProgress != null) {
OnProgress.exec(messagePrefix + "Processing files", postProcessor.getName(), (float) progress / total);
}
files = postProcessor.postProcess(files);
}
return files;
}
Aggregations