|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.daileon.supported.DomainAnnotationsHelper<T>
public class DomainAnnotationsHelper<T>
The AnnotationsHelper
class provides static methods for dealing
with domain annotations. Essentially, it provides methods that inform if
domain annotations are annotated with known annotations of a particular
framework, as well as retrieving all annotations that annotate a particular
element.
Field Summary | |
---|---|
private static Annotation[] |
EMPTY_ANNOTATIONS_ARRAY
An empty array of Annotation , used by the
getKnownAnnotation method |
Constructor Summary | |
---|---|
DomainAnnotationsHelper()
|
Method Summary | ||
---|---|---|
static
|
getAnnotation(AnnotatedElement element,
Class<T> annotationClass)
Gets a particular annotation that indirectly annotates an AnnotatedElement . |
|
static Annotation[] |
getKnownAnnotations(AnnotatedElement element)
Retrieves the known annotations of a given element. |
|
static Annotation[] |
getKnownAnnotations(Annotation[] annotationsVerified)
Retrieves the known annotations of an array of domain annotations. |
|
static boolean |
isAnnotationPresent(AnnotatedElement element,
Class<? extends Annotation> annotationClass)
Informs whether an AnnotatedElement is annotated with a
particular Annotation . |
|
private static boolean |
isTemplateAnnotation(Class<? extends Annotation> annotationClass)
Informs whether a particular Annotation is a template
annotation, which can be ClassTemplate , FieldTemplate or
MethodTemplate . |
|
private static boolean |
isValidAnnotation(Class<? extends Annotation> annotationClass)
Informs whether a particular Annotation is valid or not,
which can be Documented , Retention , Target or
DomainAnnotation . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY
Annotation
, used by the
getKnownAnnotation
method
Constructor Detail |
---|
public DomainAnnotationsHelper()
Method Detail |
---|
public static boolean isAnnotationPresent(AnnotatedElement element, Class<? extends Annotation> annotationClass)
AnnotatedElement
is annotated with a
particular Annotation
. This Annotation
is searched
recursively in the given AnnotatedElement
, which can be a
Field
, a Method
or even a Class
. Therefore, it is
possible to verify if a class element, or even if a class, is annotated
with a known annotation.
element
- The AnnotatedElement
(that is, the class element)
to be verified.annotationClass
- The Annotation
to be verified.
boolean
value that can be:
true
if the given AnnotatedElement
is annotated with a particular Annotation
;false
if the given AnnotatedElement
is not annotated with a particular Annotation
.public static Annotation[] getKnownAnnotations(AnnotatedElement element)
Retrieves the known annotations of a given element. The known annotations
are the annotations that annotate an AnnotatedElement
that is
also annotated with the DomainAnnotation
annotation. For
instance:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@FrameworkAnnotation1
@FrameworkAnnotation2
@DomainAnnotation
public @interface ANewlyCreatedDomainAnnotation {}@ANewlyCreatedDomainAnnotation
public void domainMethod() { // A business method }
In the example addressed above, @FrameworkAnnotation1
and
@FrameworkAnnotation2
are the annotations of the framework
or component that supports the creation of domain annotations; in other
words, they are the known annotations, which will be returned.
element
- An AnnotatedElement
to be verified.
null
if the
AnnotatedElement
is not annotated with
@DomainAnnotation
.public static Annotation[] getKnownAnnotations(Annotation[] annotationsVerified)
Retrieves the known annotations of an array of domain annotations. The
known annotations are the annotations that annotate each
Annotation
that is annotated with the DomainAnnotation
annotation.
annotationsVerified
- An array of domain annotations.
null
if no annotations
are found the AnnotatedElement
is not annotated with
@DomainAnnotation
.public static <T extends Annotation> T getAnnotation(AnnotatedElement element, Class<T> annotationClass)
AnnotatedElement
. For instance if
@FrameworkAnnotation
annotates a domain annotation, and this
domain annotation annotates a particular element, then this method is
capable of retrieving @FrameworkAnnotation
from the element
annotated with the domain annotation. If the searched annotation does not
indirectly annotates the element, then null
is returned.
element
- The AnnotatedElement
, annotated with a domain
annotation.annotationClass
- The Class
of the annotation being searched.
Annotation
that indirectly annotates the given
element, or null
if the annotation is not found in
the element.private static boolean isValidAnnotation(Class<? extends Annotation> annotationClass)
Annotation
is valid or not,
which can be Documented
, Retention
, Target
or
DomainAnnotation
.
annotationClass
- The Class
that represents the annotation to be
verified.
boolean
value that can be:
true
if the given Annotation
is
valid;false
if the given Annotation
is
not valid.private static boolean isTemplateAnnotation(Class<? extends Annotation> annotationClass)
Annotation
is a template
annotation, which can be ClassTemplate
, FieldTemplate
or
MethodTemplate
.
annotationClass
- The Class
that represents the annotation to be
verified.
boolean
value that can be:
true
if the given Annotation
is a
template annotation;false
if the given Annotation
is
not a template annotation.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |