Fork me on GitHub

Commons AnnotationUtil

org.onehippo.forge.utilities.commons.AnnotationUtil

Static utility class for getting (annotated) fields and methods from classes, using reflection. It has with following methods:

  /**
   * Find a class for given name, loaded from current thread's class loader.
   */
   <T> Class<T> findClass(String name)

  /**
   * Get the fields of a class that are annotated with specific annotation.
   */
   Collection<Field> getAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotationClass) {

  /**
   * Get the methods of a class that are annotated with specific annotation.
   */
   Collection<Field> getAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> annotationClass) {

  /**
   * Get all fields of a class, including all fields of it's super classes.
   */
   Collection<Field> getClassFields(Class<?> clazz)

  /**
  * Get the methods of a class, including all methods of it's super classes.
  */
   Collection<Method> getClassMethods(Class<?> clazz)