Search in sources :

Example 1 with ActionType

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();
    }
}
Also used : PrintStream(java.io.PrintStream) ActionType(org.talend.sdk.component.api.service.ActionType) JarArchive(org.apache.xbean.finder.archive.JarArchive) FileArchive(org.apache.xbean.finder.archive.FileArchive) File(java.io.File) AnnotationFinder(org.apache.xbean.finder.AnnotationFinder)

Aggregations

File (java.io.File)1 PrintStream (java.io.PrintStream)1 AnnotationFinder (org.apache.xbean.finder.AnnotationFinder)1 FileArchive (org.apache.xbean.finder.archive.FileArchive)1 JarArchive (org.apache.xbean.finder.archive.JarArchive)1 ActionType (org.talend.sdk.component.api.service.ActionType)1