use of org.apache.johnzon.mapper.MapperBuilder in project component-runtime by Talend.
the class Generator method generatedUi.
private static void generatedUi(final File generatedDir) throws Exception {
final File file = new File(generatedDir, "generated_ui.adoc");
try (final PrintStream stream = new PrintStream(new WriteIfDifferentStream(file))) {
stream.println("");
stream.println("[role=\"table-striped table-hover table-ordered\",options=\"header,autowidth\"]");
stream.println("|====");
stream.println("|API|Description|Generated property metadata");
final File api = jarLocation(Ui.class);
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
final AnnotationFinder finder = new AnnotationFinder(api.isDirectory() ? new FileArchive(loader, api) : new JarArchive(loader, api.toURI().toURL()));
final ParameterExtensionEnricher enricher = new UiParameterEnricher();
final Mapper mapper = new MapperBuilder().build();
finder.findAnnotatedClasses(Ui.class).stream().sorted(Comparator.comparing(Class::getName)).forEach(type -> {
final Map<String, String> meta = enricher.onParameterAnnotation("theparameter", Object.class, generateAnnotation(type)).entrySet().stream().collect(toMap(e -> e.getKey().replace("tcomp::", ""), Map.Entry::getValue));
stream.println("|@" + type.getName() + "|" + extractDoc(type) + "|" + mapper.writeObjectAsString(meta).replace("|", "\\|"));
});
stream.println("|====");
stream.println();
}
}
Aggregations