code: private static <T> T getAnnotationValue(Annotation annotation, String value, Class<T> expectedType) {
          Class<? extends Annotation> annotationType = annotation.annotationType();
          Method valueMethod;
          try {
              valueMethod = annotationType.getDeclaredMethod(value);
          } catch (NoSuchMethodException e) {
              throw new IllegalStateException("Cannot resolve required method '" + value + "()' for '" + annotationType + "'.");
          }
          Object elementValue;
          try {
              elementValue = valueMethod.invoke(annotation);
          } catch (ReflectiveOperationException e) {
              throw new IllegalStateException("Cannot invoke method value() for " + annotationType);
          }
          return elementValue != null ? expectedType.cast(elementValue) : null;
      }
docs: Return a value from an annotation.
  
  @param annotation
  The annotation.
  @param value
  The value.
  @param expectedType
  The expected type.
  @param <T>
  The expected type.
  @return The value.