@@ -488,45 +488,6 @@ else if (Field.class.isAssignableFrom(objectClass)) {
488488 }
489489 }
490490
491- private static <T extends AnnotatedElement > void
492- populateCache (final Class <?> scannedClass , final List <Class <?>> inherited ,
493- final Class <? extends Annotation > annotationClass ,
494- CacheMap <T > cacheMap , T [] declaredElements )
495- {
496- // Add inherited elements
497- for (final Class <?> inheritedClass : inherited ) {
498- final List <T > annotatedElements =
499- cacheMap .getList (inheritedClass , annotationClass );
500-
501- if (annotatedElements != null && !annotatedElements .isEmpty ()) {
502- final List <T > scannedElements =
503- cacheMap .makeList (scannedClass , annotationClass );
504-
505- scannedElements .addAll (annotatedElements );
506- }
507- }
508-
509- // Add declared elements
510- if (declaredElements != null && declaredElements .length > 0 ) {
511- List <T > scannedElements = null ;
512-
513- for (final T t : declaredElements ) {
514- if (t .getAnnotation (annotationClass ) != null ) {
515- if (scannedElements == null ) {
516- scannedElements = cacheMap .makeList (scannedClass , annotationClass );
517- }
518- scannedElements .add (t );
519- }
520- }
521- }
522-
523- // If there were no elements for this query, map an empty
524- // list to mark the query complete
525- if (cacheMap .getList (scannedClass , annotationClass ) == null ) {
526- cacheMap .putList (scannedClass , annotationClass , Collections .<T >emptyList ());
527- }
528- }
529-
530491 /**
531492 * Gets the specified field of the given class, or null if it does not exist.
532493 */
@@ -662,7 +623,50 @@ public static int compare(final Class<?> c1, final Class<?> c2) {
662623
663624 // -- Helper methods --
664625
626+ /**
627+ * Populates the cache of annotated elements for a particular class by looking
628+ * for all inherited and declared instances annotated with the specified
629+ * annotationClass. If no matches are found, an empty mapping is created to
630+ * mark this class complete.
631+ */
632+ private static <T extends AnnotatedElement > void
633+ populateCache (final Class <?> scannedClass , final List <Class <?>> inherited ,
634+ final Class <? extends Annotation > annotationClass ,
635+ CacheMap <T > cacheMap , T [] declaredElements )
636+ {
637+ // Add inherited elements
638+ for (final Class <?> inheritedClass : inherited ) {
639+ final List <T > annotatedElements =
640+ cacheMap .getList (inheritedClass , annotationClass );
665641
642+ if (annotatedElements != null && !annotatedElements .isEmpty ()) {
643+ final List <T > scannedElements =
644+ cacheMap .makeList (scannedClass , annotationClass );
645+
646+ scannedElements .addAll (annotatedElements );
647+ }
648+ }
649+
650+ // Add declared elements
651+ if (declaredElements != null && declaredElements .length > 0 ) {
652+ List <T > scannedElements = null ;
653+
654+ for (final T t : declaredElements ) {
655+ if (t .getAnnotation (annotationClass ) != null ) {
656+ if (scannedElements == null ) {
657+ scannedElements = cacheMap .makeList (scannedClass , annotationClass );
658+ }
659+ scannedElements .add (t );
660+ }
661+ }
662+ }
663+
664+ // If there were no elements for this query, map an empty
665+ // list to mark the query complete
666+ if (cacheMap .getList (scannedClass , annotationClass ) == null ) {
667+ cacheMap .putList (scannedClass , annotationClass , Collections .<T >emptyList ());
668+ }
669+ }
666670
667671 // -- Deprecated methods --
668672
@@ -727,6 +731,8 @@ public static Type getGenericType(final Field field, final Class<?> type) {
727731 return GenericUtils .getFieldType (field , type );
728732 }
729733
734+ // -- Helper classes --
735+
730736 /**
731737 * Convenience class to further type narrow {@link CacheMap} to {@link Field}s.
732738 */
0 commit comments