Example #1
0
  public <A extends Annotation> Map<String, A> getAnnotations(
      final Class<A> annotationType, final boolean climbTree) {
    final Map<String, A> annotations = new HashMap<String, A>();

    getAnnotations(this.type, annotationType, annotations, climbTree);

    return annotations;
  }
Example #2
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);
    }
  }