in codegen/src/main/java/demoapp/codegen/demoshowcases/value/ValueTypeGenTemplate.java [303:356]
public void generate(final Consumer<File> onSourceGenerated) {
for(var template: config.getTemplates()) {
val templateFile = template.templateFile(config);
val genTarget = template.outputFile(config);
val templateVars = new TemplateVars(template.generator);
templateVars.putAll(config.templateVariables);
templateVars.put("java-package", template.javaPackage(config));
templateVars.put("showcase-name", config.showcaseName);
templateVars.put("showcase-preamble", config.getPreamble());
templateVars.put("showcase-caveat", (config.getCaveat() != null ? config.getCaveat() + "\n\n" : ""));
templateVars.put("showcase-note-if-causeway-specific", (config.isCausewaySpecific() ? "NOTE: This is an Apache Causeway specific data type.\n\n": ""));
templateVars.put("showcase-simple-type", config.getShowcaseValueSimpleType());
templateVars.put("showcase-fully-qualified-type", config.showcaseValueFullyQualifiedType);
templateVars.put("showcase-simple-type-boxed",
Optional.ofNullable(ClassUtils.resolvePrimitiveClassName(config.showcaseValueFullyQualifiedType))
.map(ClassUtils::resolvePrimitiveIfNecessary)
.map(Class::getName)
.orElse(config.getShowcaseValueSimpleType()));
templateVars.put("showcase-simple-type-getter-prefix",
Optional.ofNullable(ClassUtils.resolvePrimitiveClassName(config.showcaseValueFullyQualifiedType))
.map(cls->boolean.class.equals(cls) ? "is" : "get")
.orElse("get"));
templateVars.put("showcase-jaxb-adapter-type", (config.getJaxbAdapter() != null ? "@XmlJavaTypeAdapter(" + config.getJaxbAdapter() + ".class)\n " : "" ));
templateVars.put("showcase-java-package", config.javaPackage);
templateVars.put("showcase-value-semantics-provider", config.showcaseValueSemantics);
templateVars.put("generated-file-notice", template.generator.formatAsComment(config.generatedFileNotice));
templateVars.put("jdo-type-support-notice", config.getJdoTypeSupportNotice());
templateVars.put("jpa-type-support-notice", config.getJpaTypeSupportNotice());
templateVars.put("jaxb-type-support-notice", config.getJaxbTypeSupportNotice());
// allow for ADOC IDE tools, to properly resolve include statements,
// that is referenced (template) files should exist
if(template.generator.isDoc()) {
templateVars.putRaw("$Template", config.showcaseName);
// purge any TemplateVariant occurrences in ADOC templates
Stream.of(TemplateVariant.values())
.map(TemplateVariant::getSuffix)
.filter(_Strings::isNotEmpty)
.forEach(variantSuffix->templateVars.putRaw(variantSuffix, ""));
}
generateFromTemplate(templateVars, templateFile, genTarget);
onSourceGenerated.accept(genTarget);
}
}