Class AnnotationModule


  • public class AnnotationModule
    extends java.lang.Object
    A helper module which provides functionality for getting information from annotations.
    Author:
    Collin Alpert
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  AnnotationModule.AnnotationInfo<A extends java.lang.annotation.Annotation>
      A helper class for determining information of an annotation above a field.
    • Method Summary

      Modifier and Type Method Description
      <A extends java.lang.annotation.Annotation>
      AnnotationModule.AnnotationInfo<A>
      getAnnotationInfo​(java.lang.reflect.Field field, java.lang.Class<A> annotationClass)
      Gets information to an annotation for a field.
      <A extends java.lang.annotation.Annotation>
      AnnotationModule.AnnotationInfo<A>
      getAnnotationInfo​(java.lang.reflect.Field field, java.lang.Class<A> annotationClass, java.util.function.Function<A,​java.lang.Boolean> additionalCondition)
      Gets information to an annotation for a field and performs an additional condition if the field has been annotated.
      static AnnotationModule getInstance()  
      <A extends java.lang.annotation.Annotation>
      boolean
      hasAnnotation​(java.lang.reflect.Field field, java.lang.Class<A> annotationClass)
      Checks if a field was annotated with a specific annotation.
      <A extends java.lang.annotation.Annotation>
      boolean
      hasAnnotation​(java.lang.reflect.Field field, java.lang.Class<A> annotationClass, java.util.function.Function<A,​java.lang.Boolean> additionalCondition)
      Checks if a field was annotated with a specific annotation and performs an additional condition if so.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • hasAnnotation

        public <A extends java.lang.annotation.Annotation> boolean hasAnnotation​(java.lang.reflect.Field field,
                                                                                 java.lang.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 java.lang.annotation.Annotation> boolean hasAnnotation​(java.lang.reflect.Field field,
                                                                                 java.lang.Class<A> annotationClass,
                                                                                 java.util.function.Function<A,​java.lang.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 java.lang.annotation.Annotation> AnnotationModule.AnnotationInfo<A> getAnnotationInfo​(java.lang.reflect.Field field,
                                                                                                                java.lang.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 java.lang.annotation.Annotation> AnnotationModule.AnnotationInfo<A> getAnnotationInfo​(java.lang.reflect.Field field,
                                                                                                                java.lang.Class<A> annotationClass,
                                                                                                                java.util.function.Function<A,​java.lang.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.