Search in sources :

Example 1 with ConditionParameterEnricher

use of org.talend.sdk.component.runtime.manager.reflect.parameterenricher.ConditionParameterEnricher in project component-runtime by Talend.

the class Generator method generatedConditions.

private static void generatedConditions(final File generatedDir) throws Exception {
    final File file = new File(generatedDir, "generated_conditions.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|Name|Description|Metadata Sample");
        final File api = jarLocation(Condition.class);
        final ClassLoader loader = Thread.currentThread().getContextClassLoader();
        final ConditionParameterEnricher enricher = new ConditionParameterEnricher();
        final Mapper mapper = new MapperBuilder().build();
        final AnnotationFinder finder = new AnnotationFinder(api.isDirectory() ? new FileArchive(loader, api) : new JarArchive(loader, api.toURI().toURL()));
        finder.findAnnotatedClasses(Condition.class).stream().sorted(comparing(Class::getName)).forEach(type -> stream.println("|@" + type.getName() + "|" + type.getAnnotation(Condition.class).value() + "|" + extractDoc(type) + "|" + mapper.writeObjectAsString(enricher.onParameterAnnotation("test", String.class, generateAnnotation(type))).replace("tcomp::", "")));
        stream.println("|====");
        stream.println();
    }
}
Also used : Condition(org.talend.sdk.component.api.configuration.condition.meta.Condition) PrintStream(java.io.PrintStream) ConditionParameterEnricher(org.talend.sdk.component.runtime.manager.reflect.parameterenricher.ConditionParameterEnricher) MapperBuilder(org.apache.johnzon.mapper.MapperBuilder) Mapper(org.apache.johnzon.mapper.Mapper) 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 Mapper (org.apache.johnzon.mapper.Mapper)1 MapperBuilder (org.apache.johnzon.mapper.MapperBuilder)1 AnnotationFinder (org.apache.xbean.finder.AnnotationFinder)1 FileArchive (org.apache.xbean.finder.archive.FileArchive)1 JarArchive (org.apache.xbean.finder.archive.JarArchive)1 Condition (org.talend.sdk.component.api.configuration.condition.meta.Condition)1 ConditionParameterEnricher (org.talend.sdk.component.runtime.manager.reflect.parameterenricher.ConditionParameterEnricher)1