public static Method findAnnotatedGetter ( Class < ? > cls , Class < ? extends Annotation > class1 ) { for ( final Method m : cls . getDeclaredMethods ( ) ) { if ( m . getAnnotation ( class1 ) != null ) { if ( ! m . getReturnType ( ) . equals ( Void . TYPE ) && ! Modifier . isAbstract ( m . getModifiers ( ) ) && ( m . getParameterTypes ( ) . length == 0 ) // must be public && ( Modifier . isPublic ( m . getModifiers ( ) ) ) ) { return m ; } } } return null ; }
Find a getter with the specified annotation . getter must be annotated return a value not be abstract and not take any parameters and is public .