private ClassInfoList getClassesWithFieldOrMethodAnnotation ( final RelType relType ) { final boolean isField = relType == RelType . CLASSES_WITH_FIELD_ANNOTATION ; if ( ! ( isField ? scanResult . scanSpec . enableFieldInfo : scanResult . scanSpec . enableMethodInfo ) || ! scanResult . scanSpec . enableAnnotationInfo ) { throw new IllegalArgumentException ( "Please call ClassGraph#enable" + ( isField ? "Field" : "Method" ) + "Info() and " + "#enableAnnotationInfo() before #scan()" ) ; } final ReachableAndDirectlyRelatedClasses classesWithDirectlyAnnotatedFieldsOrMethods = this . filterClassInfo ( relType , /* strictWhitelist = */ ! isExternalClass ) ; final ReachableAndDirectlyRelatedClasses annotationsWithThisMetaAnnotation = this . filterClassInfo ( RelType . CLASSES_WITH_ANNOTATION , /* strictWhitelist = */ ! isExternalClass , ClassType . ANNOTATION ) ; if ( annotationsWithThisMetaAnnotation . reachableClasses . isEmpty ( ) ) { // This annotation does not meta-annotate another annotation that annotates a method return new ClassInfoList ( classesWithDirectlyAnnotatedFieldsOrMethods , /* sortByName = */ true ) ; } else { // Take the union of all classes with fields or methods directly annotated by this annotation, // and classes with fields or methods meta-annotated by this annotation final Set < ClassInfo > allClassesWithAnnotatedOrMetaAnnotatedFieldsOrMethods = new LinkedHashSet <> ( classesWithDirectlyAnnotatedFieldsOrMethods . reachableClasses ) ; for ( final ClassInfo metaAnnotatedAnnotation : annotationsWithThisMetaAnnotation . reachableClasses ) { allClassesWithAnnotatedOrMetaAnnotatedFieldsOrMethods . addAll ( metaAnnotatedAnnotation . filterClassInfo ( relType , /* strictWhitelist = */ ! metaAnnotatedAnnotation . isExternalClass ) . reachableClasses ) ; } return new ClassInfoList ( allClassesWithAnnotatedOrMetaAnnotatedFieldsOrMethods , classesWithDirectlyAnnotatedFieldsOrMethods . directlyRelatedClasses , /* sortByName = */ true ) ; } }
Get the classes that have this class as a field method or method parameter annotation .