private static Set < Annotation > getAnnotations ( final Annotation [ ] annotations , final Class < ? extends Annotation > neededAnnotationType ) { final Set < Annotation > ret = new HashSet <> ( ) ; for ( final Annotation annotation : annotations ) { annotation . annotationType ( ) . getAnnotations ( ) ; final Annotation [ ] metaAnnotations = annotation . annotationType ( ) . getAnnotations ( ) ; for ( final Annotation metaAnnotation : metaAnnotations ) { if ( metaAnnotation . annotationType ( ) . equals ( neededAnnotationType ) ) { ret . add ( annotation ) ; } } } return ret ; }
Gets annotations match the needed annotation type from the specified annotation .