use of org.talend.sdk.component.api.service.ActionType in project component-runtime by Talend.
the class Generator method generatedActions.
private static void generatedActions(final File generatedDir) throws Exception {
final File file = new File(generatedDir, "generated_actions.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|Type|Description|Return type|Sample returned type");
final File api = jarLocation(ActionType.class);
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
final AnnotationFinder finder = new AnnotationFinder(api.isDirectory() ? new FileArchive(loader, api) : new JarArchive(loader, api.toURI().toURL()));
finder.findAnnotatedClasses(ActionType.class).stream().sorted(Comparator.comparing(t -> t.getAnnotation(ActionType.class).value() + "#" + t.getSimpleName())).forEach(type -> {
final ActionType actionType = type.getAnnotation(ActionType.class);
final Class<?> returnedType = actionType.expectedReturnedType();
stream.println("|@" + type.getName() + "|" + actionType.value() + "|" + extractDoc(type) + "|" + (returnedType == Object.class ? "any" : returnedType.getSimpleName()) + "|" + (returnedType != Object.class ? "`" + sample(returnedType).replace("\n", "") + "`" : "-"));
});
stream.println("|====");
stream.println();
}
}
Aggregations