コード例 #1
0
 private boolean isAnnotationPresent(
     Annotation[] annotations, Class<? extends Annotation> annotationClass) {
   for (Annotation annotation : annotations) {
     if (annotationClass.isInstance(annotation)) {
       return true;
     }
   }
   return false;
 }
コード例 #2
0
  private String getValue(Annotation[] annotations, Class<? extends Annotation> annotationClass) {
    for (Annotation annotation : annotations) {
      if (annotationClass.isInstance(annotation)) {
        Method valueMethod = ReflectionUtils.findMethod(annotationClass, "value");
        if (valueMethod != null) {
          return (String) ReflectionUtils.invokeMethod(valueMethod, annotation);
        } else {
          return null;
        }
      }
    }

    return null;
  }