in scrooge-generator/src/main/scala/com/twitter/scrooge/java_generator/ApacheJavaGenerator.scala [281:335]
def apply(
serviceOptions: Set[ServiceOption],
outputPath: File,
dryRun: Boolean = false,
genAdapt: Boolean = false
): Iterable[File] = {
// validate default annotations applied to structs during generation
validateStructAnnotations(doc.structs)
// TODO: Implement serviceOptions (WithFinagle, etc)
val generatedFiles = new mutable.ListBuffer[File]
val packageDir = namespacedFolder(outputPath, namespace.fullName, dryRun)
def renderFile(templateName: String, controller: TypeController) = {
val fileContent = renderMustache(templateName, controller)
val file = new File(packageDir, controller.name + ".java")
if (!dryRun) {
val writer = new FileWriter(file)
try {
writer.write(fileContent)
} finally {
writer.close()
}
}
file
}
if (doc.consts.nonEmpty) {
generatedFiles += renderFile(
"consts.mustache",
new ConstController(doc.consts, this, Some(namespace))
)
}
doc.enums.foreach { enum =>
generatedFiles += renderFile(
"enum.mustache",
new EnumController(enum, serviceOptions, this, Some(namespace)))
}
doc.structs.foreach { struct =>
generatedFiles += renderFile(
"struct.mustache",
new StructController(struct, serviceOptions, false, this, Some(namespace), validator)
)
}
doc.services.foreach { service =>
generatedFiles += renderFile(
"service.mustache",
new ServiceController(service, serviceOptions, this, Some(namespace))
)
}
generatedFiles
}