ThriftServiceMetadataRenderer serviceRenderer = new ThriftServiceMetadataRenderer(serviceMap.build());
TemplateLoader tl = new TemplateLoader(ImmutableList.of("thrift/common.st"),
ImmutableMap.of(
ThriftType.class, thriftTypeRenderer,
ThriftServiceMetadata.class, serviceRenderer,
Requiredness.class, new FieldRequirednessRenderer()));
ThriftContext ctx = new ThriftContext(packageName, ImmutableList.copyOf(includes.build()), thriftTypes, thriftServices, namespaceMap);
ST template = tl.load("thriftfile");
template.add("context", ctx);
template.write(new AutoIndentWriter(outputStreamWriter));
outputStreamWriter.flush();