Search in sources :

Example 1 with ConfigurationTypeParameterEnricher

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

the class Generator method generatedTypes.

private static void generatedTypes(final File generatedDir) throws Exception {
    final File file = new File(generatedDir, "generated_configuration-types.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|Metadata sample");
        final File api = jarLocation(ConfigurationType.class);
        final ClassLoader loader = Thread.currentThread().getContextClassLoader();
        final ConfigurationTypeParameterEnricher enricher = new ConfigurationTypeParameterEnricher();
        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(ConfigurationType.class).stream().sorted(comparing(Class::getName)).forEach(type -> stream.println("|" + type.getName() + "|" + type.getAnnotation(ConfigurationType.class).value() + "|" + extractDoc(type) + "|" + mapper.writeObjectAsString(enricher.onParameterAnnotation("value", String.class, generateAnnotation(type)))));
        stream.println("|====");
        stream.println();
    }
}
Also used : MapperBuilder(org.apache.johnzon.mapper.MapperBuilder) ConfigurationType(org.talend.sdk.component.api.configuration.type.meta.ConfigurationType) PrintStream(java.io.PrintStream) Mapper(org.apache.johnzon.mapper.Mapper) ConfigurationTypeParameterEnricher(org.talend.sdk.component.runtime.manager.reflect.parameterenricher.ConfigurationTypeParameterEnricher) 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 ConfigurationType (org.talend.sdk.component.api.configuration.type.meta.ConfigurationType)1 ConfigurationTypeParameterEnricher (org.talend.sdk.component.runtime.manager.reflect.parameterenricher.ConfigurationTypeParameterEnricher)1