Class AnnotationSugar

java.lang.Object
org.refcodes.runtime.AnnotationSugar

public class AnnotationSugar extends Object
Declarative syntactic sugar which may be statically imported in order to allow declarative definitions for Annotation related functionality.
  • Constructor Details

    • AnnotationSugar

      public AnnotationSugar()
  • Method Details

    • annotations

      public static Set<Annotation> annotations(Class<?> aClass)
      Gatherers all annotations annotating a provided Class.
      Parameters:
      aClass - the Class for which to gather all annotations.
      Returns:
      ReflectionUtility.the Set containing all according annotations annotating the given Class
    • annotations

      public static Set<Annotation> annotations(Field aField)
      Gatherers all annotations annotating a provided Field.
      Parameters:
      aField - the Field for which to gather all annotations.
      Returns:
      ReflectionUtility.the Set containing all according annotations annotating the given Field
    • annotations

      public static Set<Annotation> annotations(Method aMethod)
      Gatherers all annotations annotating a provided Method.
      Parameters:
      aMethod - the Method for which to gather all annotations.
      Returns:
      ReflectionUtility.the Set containing all according annotations annotating the given Method
    • annotations

      public static Set<Annotation> annotations(Object aObj)
      Gatherers all annotations annotating a provided Object.
      Parameters:
      aObj - the Object for which to gather all annotations.
      Returns:
      ReflectionUtility.the Set containing all according annotations annotating the given Object
    • findAnnotation

      public static Annotation findAnnotation(Class<? extends Annotation> aAnnotation, Class<?> aClass)
      Seeks for an Annotation of the given type annotating a provided Class, also reckoning annotations nested inside annotations (recursively).
      Parameters:
      aAnnotation - the Annotation type for which to seek.
      aClass - the Class which's annotations to crawl.
      Returns:
      ReflectionUtility.the Annotation annotating the given Class or null if none was found
    • findAnnotation

      public static Annotation findAnnotation(Class<? extends Annotation> aAnnotation, Field aField)
      Seeks for an Annotation of the given type annotating a provided Field, also reckoning annotations nested inside annotations (recursively).
      Parameters:
      aAnnotation - the Annotation type for which to seek.
      aField - the Field which's annotations to crawl.
      Returns:
      ReflectionUtility.the Annotation annotating the given Field or null if none was found
    • findAnnotation

      public static Annotation findAnnotation(Class<? extends Annotation> aAnnotation, Method aMethod)
      Seeks for an Annotation of the given type annotating a provided Method, also reckoning annotations nested inside annotations (recursively).
      Parameters:
      aAnnotation - the Annotation type for which to seek.
      aMethod - the Method which's annotations to crawl.
      Returns:
      ReflectionUtility.the Annotation annotating the given Method or null if none was found
    • findAnnotation

      public static Annotation findAnnotation(Class<? extends Annotation> aAnnotation, Object aObj)
      Seeks for an Annotation of the given type annotating a provided Object, also reckoning annotations nested inside annotations (recursively).
      Parameters:
      aAnnotation - the Annotation type for which to seek.
      aObj - the Object which's annotations to crawl.
      Returns:
      ReflectionUtility.the Annotation annotating the given Object or null if none was found
    • hasAnnotation

      public static boolean hasAnnotation(Class<? extends Annotation> aAnnotation, Class<?> aClass)
      Tests if an Annotation of the given type annotates a provided Class, also reckoning annotations nested inside annotations (recursively).
      Parameters:
      aAnnotation - the Annotation type for which to seek.
      aClass - the Class which's annotations to crawl.
      Returns:
      ReflectionUtility.True in case the Annotation annotates the given Class.
    • hasAnnotation

      public static boolean hasAnnotation(Class<? extends Annotation> aAnnotation, Field aField)
      Tests if an Annotation of the given type annotates a provided Field, also reckoning annotations nested inside annotations (recursively).
      Parameters:
      aAnnotation - the Annotation type for which to seek.
      aField - the Field which's annotations to crawl.
      Returns:
      ReflectionUtility.True in case the Annotation annotates the given Field.
    • hasAnnotation

      public static boolean hasAnnotation(Class<? extends Annotation> aAnnotation, Method aMethod)
      Tests if an Annotation of the given type annotates a provided Method, also reckoning annotations nested inside annotations (recursively).
      Parameters:
      aAnnotation - the Annotation type for which to seek.
      aMethod - the Method which's annotations to crawl.
      Returns:
      ReflectionUtility.True in case the Annotation annotates the given Method.
    • hasAnnotation

      public static boolean hasAnnotation(Class<? extends Annotation> aAnnotation, Object aObj)
      Tests if an Annotation of the given type annotates a provided Object, also reckoning annotations nested inside annotations (recursively).
      Parameters:
      aAnnotation - the Annotation type for which to seek.
      aObj - the Object which's annotations to crawl.
      Returns:
      ReflectionUtility.True in case the Annotation annotates the given Object.