### Question:
ReflectionHelper { @SuppressWarnings("unchecked") public static <T> T getAnnotationParameter(Annotation annotation, String parameterName, Class<T> type) { try { Method m = annotation.getClass().getMethod( parameterName ); Object o = m.invoke( annotation ); if ( o.getClass().getName().equals( type.getName() ) ) { return ( T ) o; } else { String msg = "Wrong parameter type. Expected: " + type.getName() + " Actual: " + o.getClass().getName(); throw new ValidationException( msg ); } } catch ( NoSuchMethodException e ) { String msg = "The specified annotation defines no parameter '" + parameterName + "'."; throw new ValidationException( msg, e ); } catch ( IllegalAccessException e ) { String msg = "Unable to get '" + parameterName + "' from " + annotation.getClass().getName(); throw new ValidationException( msg, e ); } catch ( InvocationTargetException e ) { String msg = "Unable to get '" + parameterName + "' from " + annotation.getClass().getName(); throw new ValidationException( msg, e ); } } private  ReflectionHelper(); @SuppressWarnings("unchecked") static T getAnnotationParameter(Annotation annotation, String parameterName, Class<T> type); static String getPropertyName(Member member); static Class<?> getType(Member member); static Class<?> getAnnotations(Member member); static Type typeOf(Member member); static Object getValue(Member member, Object object); static void setAccessibility(Member member); static Class<?> loadClass(String name, Class<?> caller); static Type getIndexedType(Type type); static boolean isIterable(Type type); static boolean isMap(Type type); static boolean isList(Type type); static Object getIndexedValue(Object value, Integer index); static Object getMappedValue(Object value, Object key); static boolean containsMember(Class<?> clazz, String property); static boolean containsField(Class<?> clazz, String fieldName); static Field getField(Class<?> clazz, String fieldName); static boolean containsMethod(Class<?> clazz, String methodName); static Method getMethod(Class<?> clazz, String methodName); static Class<?> classForName(String name, Class<?> caller); static Class<?> boxedTyp(Type primitiveType);  }### Answer:
@Test public void testGetMessageParamter() { NotNull testAnnotation = new NotNull() { public String message() { return "test"; } public Class<?>[] groups() { return new Class<?>[] { Default.class }; } public Class<? extends ConstraintPayload>[] payload() { @SuppressWarnings("unchecked") Class<? extends ConstraintPayload>[] classes = new Class[] { }; return classes; } public Class<? extends Annotation> annotationType() { return this.getClass(); } }; String message = ReflectionHelper.getAnnotationParameter( testAnnotation, "message", String.class ); assertEquals( "test", message, "Wrong message" ); Class<?>[] group = ReflectionHelper.getAnnotationParameter( testAnnotation, "groups", Class[].class ); assertEquals( group[0], Default.class, "Wrong message" ); try { ReflectionHelper.getAnnotationParameter( testAnnotation, "message", Integer.class ); fail(); } catch ( ValidationException e ) { assertTrue( e.getMessage().startsWith( "Wrong parameter type." ), "Wrong exception message" ); } try { ReflectionHelper.getAnnotationParameter( testAnnotation, "foo", Integer.class ); fail(); } catch ( ValidationException e ) { assertTrue( e.getMessage().startsWith( "The specified annotation defines no parameter" ), "Wrong exception message" ); } }