package yokohama.unit.translator;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Optional;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import yokohama.unit.annotations.As;

public class DataConverterFinder {
    public Optional<Method> find(Class<?> returnType, ClassLoader classLoader) {
        ClassPathScanningCandidateComponentProvider scanner =
                new ClassPathScanningCandidateComponentProvider(false);
        scanner.setResourceLoader(new DefaultResourceLoader(classLoader));
        scanner.addIncludeFilter(new AnnotationTypeFilter(As.class));

        return scanner.findCandidateComponents("").stream()
            .map(BeanDefinition::getBeanClassName)
            .flatMap(className -> {
                try {
                    Class<?> clazz = Class.forName(className, false, classLoader);
                    return Arrays.<Method>asList(clazz.getMethods()).stream()
                            .filter(method -> true &&
                                    method.getReturnType().equals(returnType) &&
                                    method.getParameterCount() == 1 &&
                                    method.getParameterTypes()[0].equals(String.class));
                } catch (ClassNotFoundException e) {
                    throw new RuntimeException(e);
                }
            }).findFirst();
    }
}

@@ -103,24 +103,83 @@
 va.util.
-Optional
+List;%0Aimport java.util.Optional;%0Aimport java.util.stream.Collectors
 ;%0Aimport
@@ -487,16 +487,59 @@
 ions.As;
+%0Aimport yokohama.unit.annotations.GroovyAs;
 %0A%0Apublic
@@ -1675,16 +1675,16 @@
       %7D%0A
-
         
@@ -1708,11 +1708,1255 @@
 );%0A    %7D
+%0A%0A    public List%3CMethod%3E findGroovyAs(ClassLoader classLoader) %7B%0A        ClassPathScanningCandidateComponentProvider scanner =%0A                new ClassPathScanningCandidateComponentProvider(false);%0A        scanner.setResourceLoader(new DefaultResourceLoader(classLoader));%0A        scanner.addIncludeFilter(new AnnotationTypeFilter(As.class));%0A%0A        return scanner.findCandidateComponents(%22%22).stream()%0A            .map(BeanDefinition::getBeanClassName)%0A            .flatMap(className -%3E %7B%0A                try %7B%0A                    Class%3C?%3E clazz = Class.forName(className, false, classLoader);%0A                    return Arrays.%3CMethod%3EasList(clazz.getMethods()).stream()%0A                            .filter(method -%3E true &&%0A                                    Arrays.stream(method.getAnnotations()).anyMatch(ann -%3E%0A                                            ann.annotationType().equals(GroovyAs.class)) &&%0A                                    method.getParameterCount() == 2 &&%0A                                    method.getParameterTypes()%5B1%5D.equals(Class.class));%0A                %7D catch (ClassNotFoundException e) %7B%0A                    throw new RuntimeException(e);%0A                %7D%0A            %7D).collect(Collectors.toList());%0A    %7D
 %0A%7D%0A

Add findGroovyAs method