1 12 package org.eclipse.jdt.apt.core.util; 13 14 import java.util.Collection ; 15 import java.util.List ; 16 17 import org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader; 18 import org.eclipse.jdt.core.IJavaProject; 19 20 import com.sun.mirror.apt.AnnotationProcessorFactory; 21 22 public final class AptUtil { 23 24 private AptUtil() {} 26 27 34 public static AnnotationProcessorFactory getFactoryForAnnotation( 35 final String fullyQualifiedAnnotation, 36 final IJavaProject jproj) { 37 38 AnnotationProcessorFactoryLoader loader = AnnotationProcessorFactoryLoader.getLoader(); 39 List <AnnotationProcessorFactory> factories = loader.getJava5FactoriesForProject( jproj ); 40 41 for (AnnotationProcessorFactory factory : factories) { 42 Collection <String > supportedAnnos = factory.supportedAnnotationTypes(); 43 for (String anno : supportedAnnos) { 44 if (anno.equals(fullyQualifiedAnnotation)) { 45 return factory; 46 } 47 else if ("*".equals(anno)) { return factory; 49 } 50 else if (anno.endsWith("*")) { final String prefix = anno.substring(0, 52 anno.length() - 2); 53 if (fullyQualifiedAnnotation.startsWith(prefix)) { 54 return factory; 55 } 56 } 57 } 58 } 59 60 return null; 61 } 62 63 64 65 } 66 | Popular Tags |