Class AnnotationHelper

java.lang.Object
org.apache.camel.util.AnnotationHelper

public final class AnnotationHelper extends Object
  • Constructor Details

  • Method Details

    • findMethodsWithAnnotation

      public static List<Method> findMethodsWithAnnotation(Class<?> type, Class<? extends Annotation> annotationType)
      Returns a list of methods which are annotated with the given annotation
      Parameters:
      type - the type to reflect on
      annotationType - the annotation type
      Returns:
      a list of the methods found
    • findMethodsWithAnnotation

      public static List<Method> findMethodsWithAnnotation(Class<?> type, Class<? extends Annotation> annotationType, boolean checkMetaAnnotations)
      Returns a list of methods which are annotated with the given annotation
      Parameters:
      type - the type to reflect on
      annotationType - the annotation type
      checkMetaAnnotations - check for meta annotations
      Returns:
      a list of the methods found
    • hasAnnotation

      public static boolean hasAnnotation(AnnotatedElement elem, Class<? extends Annotation> annotationType, boolean checkMetaAnnotations)
      Checks if a Class or Method are annotated with the given annotation
      Parameters:
      elem - the Class or Method to reflect on
      annotationType - the annotation type
      checkMetaAnnotations - check for meta annotations
      Returns:
      true if annotations is present
    • getAnnotationValue

      public static String getAnnotationValue(Class<?> clazz, String fqnAnnotationName)
      Checks if the class has been annotated with the given annotation (FQN class name) and if present, then returns the value attribute.
      Parameters:
      clazz - the class
      fqnAnnotationName - the FQN of the annotation
      Returns:
      null if not annotated, otherwise the value, an empty string means annotation but has no value
    • hasAnnotation

      public static boolean hasAnnotation(Class<?> clazz, String fqnAnnotationName)
      Checks if the class has been annotated with the given annotation (FQN class name).
      Parameters:
      clazz - the class
      fqnAnnotationName - the FQN of the annotation
      Returns:
      true if annotated or false if not
    • hasAnnotation

      public static boolean hasAnnotation(Method method, String fqnAnnotationName)
      Checks if the method has been annotated with the given annotation (FQN class name).
      Parameters:
      method - the method
      fqnAnnotationName - the FQN of the annotation
      Returns:
      true if annotated or false if not
    • getAnnotationValue

      public static String getAnnotationValue(Method method, String fqnAnnotationName)
      Checks if the method has been annotated with the given annotation (FQN class name) and if present, then returns the value attribute.
      Parameters:
      method - the method
      fqnAnnotationName - the FQN of the annotation
      Returns:
      null if not annotated, otherwise the value, an empty string means annotation but has no value
    • getAnnotationValue

      public static Object getAnnotationValue(Method method, String fqnAnnotationName, String key)
      Checks if the method has been annotated with the given annotation (FQN class name) and if present, then returns the value attribute.
      Parameters:
      method - the field
      fqnAnnotationName - the FQN of the annotation
      key - the annotation key
      Returns:
      null if not annotated, otherwise the value, an empty string means annotation but has no value
    • hasAnnotation

      public static boolean hasAnnotation(Field field, String fqnAnnotationName)
      Checks if the field has been annotated with the given annotation (FQN class name).
      Parameters:
      field - the field
      fqnAnnotationName - the FQN of the annotation
      Returns:
      true if annotated or false if not
    • getAnnotationValue

      public static String getAnnotationValue(Field field, String fqnAnnotationName)
      Checks if the field has been annotated with the given annotation (FQN class name) and if present, then returns the value attribute.
      Parameters:
      field - the field
      fqnAnnotationName - the FQN of the annotation
      Returns:
      null if not annotated, otherwise the value, an empty string means annotation but has no value
    • getAnnotationValue

      public static Object getAnnotationValue(Field field, String fqnAnnotationName, String key)
      Checks if the field has been annotated with the given annotation (FQN class name) and if present, then returns the value attribute.
      Parameters:
      field - the field
      fqnAnnotationName - the FQN of the annotation
      key - the annotation key
      Returns:
      null if not annotated, otherwise the value, an empty string means annotation but has no value