@ CheckForNull private < T extends BugAnnotation > T findPrimaryAnnotationOfType ( Class < T > cls ) { T firstMatch = null ; for ( Iterator < BugAnnotation > i = annotationIterator ( ) ; i . hasNext ( ) ; ) { BugAnnotation annotation = i . next ( ) ; if ( cls . isAssignableFrom ( annotation . getClass ( ) ) ) { if ( annotation . getDescription ( ) . endsWith ( "DEFAULT" ) ) { return cls . cast ( annotation ) ; } else if ( firstMatch == null ) { firstMatch = cls . cast ( annotation ) ; } } } return firstMatch ; }
Find the first BugAnnotation in the list of annotations that is the same type or a subtype as the given Class parameter .