public static Object getAnnotationAttribute ( final Annotation annotation , final String attributeName ) { Object object = null ; try { // Get the annotation method for the given name final Method attributeMethod = annotation . annotationType ( ) . getDeclaredMethod ( attributeName ) ; // Call the method to gets the value object = attributeMethod . invoke ( annotation ) ; } catch ( NoSuchMethodException | SecurityException e ) { LOGGER . log ( NO_ANNOTATION_PROPERTY , e , attributeName ) ; } catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) { LOGGER . log ( NO_ANNOTATION_PROPERTY_VALUE , e , attributeName ) ; } return object ; }
Retrieve an annotation property dynamically by reflection .