Class AnnotationModule


  • public class AnnotationModule
    extends Object
    A helper module which provides functionality for getting information from annotations.
    Author:
    Collin Alpert
    • Method Detail

      • hasAnnotation

        public <A extends Annotation> boolean hasAnnotation​(Field field,
                                                            Class<A> annotationClass)
        Checks if a field was annotated with a specific annotation.
        Type Parameters:
        A - The type of the annotation.
        Parameters:
        field - The field to check.
        annotationClass - The annotation to check for.
        Returns:
        True, if the field was annotated with this annotation, false otherwise.
      • hasAnnotation

        public <A extends Annotation> boolean hasAnnotation​(Field field,
                                                            Class<A> annotationClass,
                                                            Function<A,​Boolean> additionalCondition)
        Checks if a field was annotated with a specific annotation and performs an additional condition if so.
        Type Parameters:
        A - The type of the annotation.
        Parameters:
        field - The field to check.
        annotationClass - The annotation to check for.
        additionalCondition - An additional condition to perform on the annotation. This condition is only executed if the field was annotated with the specified annotation.
        Returns:
        True, if the field was annotated with this annotation and the additional condition evaluates to true, false otherwise.
      • getAnnotationInfo

        public <A extends AnnotationAnnotationModule.AnnotationInfo<A> getAnnotationInfo​(Field field,
                                                                                           Class<A> annotationClass)
        Gets information to an annotation for a field.
        Type Parameters:
        A - The type of the annotation.
        Parameters:
        field - The field to get annotation information from.
        annotationClass - The annotation to check for.
        Returns:
        Information concerning a specific annotation of a field.
      • getAnnotationInfo

        public <A extends AnnotationAnnotationModule.AnnotationInfo<A> getAnnotationInfo​(Field field,
                                                                                           Class<A> annotationClass,
                                                                                           Function<A,​Boolean> additionalCondition)
        Gets information to an annotation for a field and performs an additional condition if the field has been annotated.
        Type Parameters:
        A - The type of the annotation.
        Parameters:
        field - The field to get annotation information from.
        annotationClass - The annotation to check for.
        additionalCondition - An additional condition to perform on the annotation. This condition is only executed if the field was annotated with the specified annotation.
        Returns:
        Information concerning a specific annotation of a field.