Example #1
0
  public static <A extends Annotation> void getAnnotations(
      final Class<?> fromClass,
      final Class<A> annotationType,
      final Map<String, A> annotations,
      final boolean climbTree) {
    final Map<String, PropertyHelper> properties = PropertyHelper.getFromClass(fromClass);

    for (final Entry<String, PropertyHelper> entry : properties.entrySet()) {
      final PropertyHelper ph = entry.getValue();
      final A annotation = ph.getAnnotation(annotationType);

      if (annotation != null) {
        annotations.put(entry.getKey(), annotation);
      }
    }

    if (climbTree && !fromClass.getSuperclass().equals(Object.class)) {
      getAnnotations(fromClass.getSuperclass(), annotationType, annotations, true);
    }
  }