static String readAnnotationValue ( Annotation annotation ) { try { Method m = annotation . getClass ( ) . getMethod ( "value" ) ; return ( String ) m . invoke ( annotation ) ; } catch ( NoSuchMethodException e ) { throw new IllegalStateException ( "Encountered a configured annotation that " + "has no value parameter. This should never happen. " + annotation , e ) ; } catch ( InvocationTargetException e ) { throw new IllegalStateException ( "Encountered a configured annotation that " + "could not be read." + annotation , e ) ; } catch ( IllegalAccessException e ) { throw new IllegalStateException ( "Encountered a configured annotation that " + "could not be read." + annotation , e ) ; } }
A simple utility method that reads the String value attribute of any annotation instance .