protected boolean isDeprecated ( Class < ? > clazz , String methodName , Class < ? > ... paramTypes ) { // check if type is annotated if ( isDeprecated ( clazz ) ) { return true ; } // check if method is annotated try { Method method = clazz . getDeclaredMethod ( methodName , paramTypes ) ; if ( method . getAnnotation ( Deprecated . class ) != null ) { return true ; } } catch ( NoSuchMethodException nsme ) { // ignore and continue } // check superclass Class < ? > superClass = clazz . getSuperclass ( ) ; if ( superClass != null ) { return isDeprecated ( superClass , methodName , paramTypes ) ; } // check interfaces for ( Class < ? > iface : clazz . getInterfaces ( ) ) { return isDeprecated ( iface , methodName , paramTypes ) ; } // none found return false ; }
Returns whether the given method or any super method or interface declaration is deprecated .