Package org.apache.camel.util
Class AnnotationHelper
java.lang.Object
org.apache.camel.util.AnnotationHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindMethodsWithAnnotation
(Class<?> type, Class<? extends Annotation> annotationType) Returns a list of methods which are annotated with the given annotationfindMethodsWithAnnotation
(Class<?> type, Class<? extends Annotation> annotationType, boolean checkMetaAnnotations) Returns a list of methods which are annotated with the given annotationstatic 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.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.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.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.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.static boolean
hasAnnotation
(Class<?> clazz, String fqnAnnotationName) Checks if the class has been annotated with the given annotation (FQN class name).static boolean
hasAnnotation
(AnnotatedElement elem, Class<? extends Annotation> annotationType, boolean checkMetaAnnotations) Checks if a Class or Method are annotated with the given annotationstatic boolean
hasAnnotation
(Field field, String fqnAnnotationName) Checks if the field has been annotated with the given annotation (FQN class name).static boolean
hasAnnotation
(Method method, String fqnAnnotationName) Checks if the method has been annotated with the given annotation (FQN class name).
-
Constructor Details
-
AnnotationHelper
public AnnotationHelper()
-
-
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 onannotationType
- 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 onannotationType
- the annotation typecheckMetaAnnotations
- 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 onannotationType
- the annotation typecheckMetaAnnotations
- check for meta annotations- Returns:
- true if annotations is present
-
getAnnotationValue
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 classfqnAnnotationName
- the FQN of the annotation- Returns:
- null if not annotated, otherwise the value, an empty string means annotation but has no value
-
hasAnnotation
Checks if the class has been annotated with the given annotation (FQN class name).- Parameters:
clazz
- the classfqnAnnotationName
- the FQN of the annotation- Returns:
- true if annotated or false if not
-
hasAnnotation
Checks if the method has been annotated with the given annotation (FQN class name).- Parameters:
method
- the methodfqnAnnotationName
- the FQN of the annotation- Returns:
- true if annotated or false if not
-
getAnnotationValue
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 methodfqnAnnotationName
- the FQN of the annotation- Returns:
- null if not annotated, otherwise the value, an empty string means annotation but has no value
-
getAnnotationValue
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 fieldfqnAnnotationName
- the FQN of the annotationkey
- the annotation key- Returns:
- null if not annotated, otherwise the value, an empty string means annotation but has no value
-
hasAnnotation
Checks if the field has been annotated with the given annotation (FQN class name).- Parameters:
field
- the fieldfqnAnnotationName
- the FQN of the annotation- Returns:
- true if annotated or false if not
-
getAnnotationValue
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 fieldfqnAnnotationName
- the FQN of the annotation- Returns:
- null if not annotated, otherwise the value, an empty string means annotation but has no value
-
getAnnotationValue
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 fieldfqnAnnotationName
- the FQN of the annotationkey
- the annotation key- Returns:
- null if not annotated, otherwise the value, an empty string means annotation but has no value
-