- 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 forAnnotation
related functionality.
-
-
Constructor Summary
Constructors Constructor Description AnnotationSugar()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Set<Annotation>
annotations(Class<?> aClass)
Gatherers all annotations annotating a providedClass
.static Set<Annotation>
annotations(Object aObj)
Gatherers all annotations annotating a providedObject
.static Set<Annotation>
annotations(Field aField)
Gatherers all annotations annotating a providedField
.static Set<Annotation>
annotations(Method aMethod)
Gatherers all annotations annotating a providedMethod
.static Annotation
findAnnotation(Class<? extends Annotation> aAnnotation, Class<?> aClass)
Seeks for anAnnotation
of the given type annotating a providedClass
, also reckoning annotations nested inside annotations (recursively).static Annotation
findAnnotation(Class<? extends Annotation> aAnnotation, Object aObj)
Seeks for anAnnotation
of the given type annotating a providedObject
, also reckoning annotations nested inside annotations (recursively).static Annotation
findAnnotation(Class<? extends Annotation> aAnnotation, Field aField)
Seeks for anAnnotation
of the given type annotating a providedField
, also reckoning annotations nested inside annotations (recursively).static Annotation
findAnnotation(Class<? extends Annotation> aAnnotation, Method aMethod)
Seeks for anAnnotation
of the given type annotating a providedMethod
, also reckoning annotations nested inside annotations (recursively).static boolean
hasAnnotation(Class<? extends Annotation> aAnnotation, Class<?> aClass)
Tests if anAnnotation
of the given type annotates a providedClass
, also reckoning annotations nested inside annotations (recursively).static boolean
hasAnnotation(Class<? extends Annotation> aAnnotation, Object aObj)
Tests if anAnnotation
of the given type annotates a providedObject
, also reckoning annotations nested inside annotations (recursively).static boolean
hasAnnotation(Class<? extends Annotation> aAnnotation, Field aField)
Tests if anAnnotation
of the given type annotates a providedField
, also reckoning annotations nested inside annotations (recursively).static boolean
hasAnnotation(Class<? extends Annotation> aAnnotation, Method aMethod)
Tests if anAnnotation
of the given type annotates a providedMethod
, also reckoning annotations nested inside annotations (recursively).
-
-
-
Method Detail
-
annotations
public static Set<Annotation> annotations(Class<?> aClass)
Gatherers all annotations annotating a providedClass
.
-
annotations
public static Set<Annotation> annotations(Field aField)
Gatherers all annotations annotating a providedField
.
-
annotations
public static Set<Annotation> annotations(Method aMethod)
Gatherers all annotations annotating a providedMethod
.
-
annotations
public static Set<Annotation> annotations(Object aObj)
Gatherers all annotations annotating a providedObject
.
-
findAnnotation
public static Annotation findAnnotation(Class<? extends Annotation> aAnnotation, Class<?> aClass)
Seeks for anAnnotation
of the given type annotating a providedClass
, also reckoning annotations nested inside annotations (recursively).- Parameters:
aAnnotation
- theAnnotation
type for which to seek.aClass
- theClass
which's annotations to crawl.- Returns:
- ReflectionUtility.the
Annotation
annotating the givenClass
or null if none was found
-
findAnnotation
public static Annotation findAnnotation(Class<? extends Annotation> aAnnotation, Field aField)
Seeks for anAnnotation
of the given type annotating a providedField
, also reckoning annotations nested inside annotations (recursively).- Parameters:
aAnnotation
- theAnnotation
type for which to seek.aField
- theField
which's annotations to crawl.- Returns:
- ReflectionUtility.the
Annotation
annotating the givenField
or null if none was found
-
findAnnotation
public static Annotation findAnnotation(Class<? extends Annotation> aAnnotation, Method aMethod)
Seeks for anAnnotation
of the given type annotating a providedMethod
, also reckoning annotations nested inside annotations (recursively).- Parameters:
aAnnotation
- theAnnotation
type for which to seek.aMethod
- theMethod
which's annotations to crawl.- Returns:
- ReflectionUtility.the
Annotation
annotating the givenMethod
or null if none was found
-
findAnnotation
public static Annotation findAnnotation(Class<? extends Annotation> aAnnotation, Object aObj)
Seeks for anAnnotation
of the given type annotating a providedObject
, also reckoning annotations nested inside annotations (recursively).- Parameters:
aAnnotation
- theAnnotation
type for which to seek.aObj
- theObject
which's annotations to crawl.- Returns:
- ReflectionUtility.the
Annotation
annotating the givenObject
or null if none was found
-
hasAnnotation
public static boolean hasAnnotation(Class<? extends Annotation> aAnnotation, Class<?> aClass)
Tests if anAnnotation
of the given type annotates a providedClass
, also reckoning annotations nested inside annotations (recursively).- Parameters:
aAnnotation
- theAnnotation
type for which to seek.aClass
- theClass
which's annotations to crawl.- Returns:
- ReflectionUtility.True in case the
Annotation
annotates the givenClass
.
-
hasAnnotation
public static boolean hasAnnotation(Class<? extends Annotation> aAnnotation, Field aField)
Tests if anAnnotation
of the given type annotates a providedField
, also reckoning annotations nested inside annotations (recursively).- Parameters:
aAnnotation
- theAnnotation
type for which to seek.aField
- theField
which's annotations to crawl.- Returns:
- ReflectionUtility.True in case the
Annotation
annotates the givenField
.
-
hasAnnotation
public static boolean hasAnnotation(Class<? extends Annotation> aAnnotation, Method aMethod)
Tests if anAnnotation
of the given type annotates a providedMethod
, also reckoning annotations nested inside annotations (recursively).- Parameters:
aAnnotation
- theAnnotation
type for which to seek.aMethod
- theMethod
which's annotations to crawl.- Returns:
- ReflectionUtility.True in case the
Annotation
annotates the givenMethod
.
-
hasAnnotation
public static boolean hasAnnotation(Class<? extends Annotation> aAnnotation, Object aObj)
Tests if anAnnotation
of the given type annotates a providedObject
, also reckoning annotations nested inside annotations (recursively).- Parameters:
aAnnotation
- theAnnotation
type for which to seek.aObj
- theObject
which's annotations to crawl.- Returns:
- ReflectionUtility.True in case the
Annotation
annotates the givenObject
.
-
-