/** * Check each element of an array of classes is an annotation, and that it is in a whitelisted package. Throws * IllegalArgumentException otherwise. Returns the names of the classes as an array of strings. */ String[] getAnnotationNames(final Class<?>[] annotations) { final String[] annotationNames = new String[annotations.length]; for (int i = 0; i < annotations.length; i++) { annotationNames[i] = getAnnotationName(annotations[i]); } return annotationNames; }
/** * Get the names of non-annotation classes with the given class annotation or meta-annotation. * * @param annotation * The class annotation or meta-annotation to match. * @return The sorted list of the names of all non-annotation classes that were found with the given class * annotation during the scan, or the empty list if none. */ public List<String> getNamesOfClassesWithAnnotation(final Class<?> annotation) { return getNamesOfClassesWithAnnotation(scanSpec.getAnnotationName(annotation)); }
/** * Return the names of all annotations that have the named meta-annotation. * * @param metaAnnotation * The meta-annotation. * @return The sorted list of the names of annotations that have the given meta-annotation, or the empty list if * none. */ public List<String> getNamesOfAnnotationsWithMetaAnnotation(final Class<?> metaAnnotation) { return getNamesOfAnnotationsWithMetaAnnotation(scanSpec.getAnnotationName(metaAnnotation)); }
/** * Get the names of classes that have a method with an annotation of the given type. * * @param annotation * the method annotation. * @return The sorted list of the names of classes with a method that has an annotation of the given type, or * the empty list if none. */ public List<String> getNamesOfClassesWithMethodAnnotation(final Class<?> annotation) { return getNamesOfClassesWithMethodAnnotation(scanSpec.getAnnotationName(annotation)); }
/** * Get the names of classes that have a field with an annotation of the given type. * * @param annotation * the field annotation. * @return The sorted list of the names of classes that have a field with an annotaton of the given type, or the * empty list if none. */ public List<String> getNamesOfClassesWithFieldAnnotation(final Class<?> annotation) { return getNamesOfClassesWithFieldAnnotation(scanSpec.getAnnotationName(annotation)); }
@Override public void lookForMatches(final ScanResult scanResult, final LogNode log) { final String annotationName = getAnnotationName(annotation); for (final String classWithFieldAnnotation : scanResult .getNamesOfClassesWithFieldAnnotation(annotationName)) {
@Override public void lookForMatches(final ScanResult scanResult, final LogNode log) { final String annotationName = getAnnotationName(annotation); for (final String classWithAnnotation : scanResult .getNamesOfClassesWithAnnotation(annotationName)) { LogNode subLog = null; if (log != null) { subLog = log.log( "Matched class with annotation " + annotationName + ": " + classWithAnnotation); } try { // Call classloader final Class<?> cls = loadClassForMatchProcessor(classWithAnnotation, scanResult, log); // Process match if (cls != null) { classAnnotationMatchProcessor.processMatch(cls); } } catch (final Throwable e) { if (subLog != null) { subLog.log("Exception while processing match for class " + classWithAnnotation, e); } scanResult.addMatchProcessorException(e); } } } });
@Override public void lookForMatches(final ScanResult scanResult, final LogNode log) { final String annotationName = getAnnotationName(annotation); for (final String classWithMethodAnnotation : scanResult .getNamesOfClassesWithMethodAnnotation(annotationName)) {