private static boolean hasAnnotation ( String pkgInfo , String annotation ) { if ( ! annotation . contains ( "." ) ) { ErrorUtil . warning ( annotation + " is not a fully qualified name" ) ; } if ( pkgInfo . contains ( "@" + annotation ) ) { return true ; } int idx = annotation . lastIndexOf ( "." ) ; String annotationPackageName = annotation . substring ( 0 , idx ) ; String annotationSimpleName = annotation . substring ( idx + 1 ) ; if ( pkgInfo . contains ( "@" + annotationSimpleName ) ) { String importRegex = "import\\s*" + annotationPackageName + "(\\.\\*|\\." + annotationSimpleName + ")" ; Pattern p = Pattern . compile ( importRegex ) ; Matcher m = p . matcher ( pkgInfo ) ; if ( m . find ( ) ) { return true ; } } return false ; }
Return true if pkgInfo has the specified annotation .