|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.mmm.util.reflect.base.AnnotationUtilImpl
@Singleton @Named public class AnnotationUtilImpl
This class is a collection of utility functions for dealing with
annotations
.
getInstance()
Field Summary | |
---|---|
private static AnnotationUtilImpl |
instance
|
private ReflectionUtil |
reflectionUtil
|
Fields inherited from interface net.sf.mmm.util.reflect.api.AnnotationUtil |
---|
NO_TARGET |
Constructor Summary | |
---|---|
protected |
AnnotationUtilImpl()
The constructor. |
Method Summary | ||
---|---|---|
|
getClassAnnotation(Class<?> annotatedClass,
Class<A> annotation)
This method gets the first annotation of
the type given by annotation in the class
hierarchy of the given
annotatedClass . |
|
static AnnotationUtilImpl |
getInstance()
This method gets the singleton instance of this AnnotationUtilImpl . |
|
private
|
getInterfacesAnnotation(Class<?> annotatedType,
Class<A> annotation)
This method gets the first annotation of
the type given by annotation in the
hierarchy of the given
annotatedInterface . |
|
|
getMethodAnnotation(Method annotatedMethod,
Class<A> annotation)
This method gets the first annotation of
the type given by annotation in the
hierarchy of the given
method . |
|
protected ReflectionUtil |
getReflectionUtil()
This method gets the ReflectionUtilImpl used by this
AnnotationUtilImpl instance. |
|
|
getTypeAnnotation(Class<?> annotatedType,
Class<A> annotation)
This method gets the first annotation of
the type given by annotation in the declaration of the given
annotatedType . |
|
|
isAnnotationForType(Class<A> annotationType,
ElementType targetType)
This method determines if the given annotationType represents
an Annotation that has a Target
compatible with the given targetType . |
|
|
isRuntimeAnnotation(Class<A> annotationType)
This method determines if the given annotationType represents
an Annotation that has the Retention
runtime and can
therefore be resolved at runtime. |
|
void |
setReflectionUtil(ReflectionUtil reflectionUtil)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static AnnotationUtilImpl instance
getInstance()
private ReflectionUtil reflectionUtil
getReflectionUtil()
Constructor Detail |
---|
protected AnnotationUtilImpl()
Method Detail |
---|
public static AnnotationUtilImpl getInstance()
AnnotationUtilImpl
.getInstance()
methods and
construct new instances via the container-framework of your choice (like
plexus, pico, springframework, etc.). To wire up the dependent components
everything is properly annotated using common-annotations (JSR-250). If
your container does NOT support this, you should consider using a better
one.
protected ReflectionUtil getReflectionUtil()
ReflectionUtilImpl
used by this
AnnotationUtilImpl
instance.
ReflectionUtilImpl
to use.@Inject public void setReflectionUtil(ReflectionUtil reflectionUtil)
reflectionUtil
- the reflectionUtil to setpublic <A extends Annotation> boolean isRuntimeAnnotation(Class<A> annotationType)
annotationType
represents
an Annotation
that has the Retention
runtime
and can
therefore be resolved at runtime.
isRuntimeAnnotation
in interface AnnotationUtil
A
- is the type of the annotation to check.annotationType
- is the type of the annotation to check.
true
if the given annotationType
can be
resolved at runtime.public <A extends Annotation> boolean isAnnotationForType(Class<A> annotationType, ElementType targetType)
annotationType
represents
an Annotation
that has a Target
compatible with the given targetType
.
isAnnotationForType
in interface AnnotationUtil
A
- is the type of the annotation to check.annotationType
- is the type of the annotation to check.targetType
- is the expected target-type to check.
true
if the given annotationType
can be
used to annotate elements of the given targetType
.public <A extends Annotation> A getClassAnnotation(Class<?> annotatedClass, Class<A> annotation) throws IllegalArgumentException
annotation
of
the type given by annotation
in the class
hierarchy
of the given
annotatedClass
.annotation
is a
runtime annotation
that is
applicable
for
classes
. If the annotation
is
inherited
you may want to directly
use Class.getAnnotation(Class)
instead.
getClassAnnotation
in interface AnnotationUtil
A
- is the type of the requested annotation.annotatedClass
- is the class potentially annotated with the given
annotation
. This should NOT be an
interface
, primitive
, array
, enum
, or annotation
.annotation
- is the type of the requested annotation.
null
if neither the
annotatedClass
nor one of its
super-classes
are
annotated
with the given
annotation
.
IllegalArgumentException
- if the given annotation is no
runtime annotation
or is NOT
applicable
for
classes
.AnnotationUtil.getTypeAnnotation(Class, Class)
private <A extends Annotation> A getInterfacesAnnotation(Class<?> annotatedType, Class<A> annotation)
annotation
of
the type given by annotation
in the
hierarchy
of the given
annotatedInterface
.annotation
is a
runtime annotation
that is
applicable
for
classes
.
A
- is the type of the requested annotation.annotatedType
- is the type potentially implementing an interface
annotated with the given annotation
. This should NOT be
an primitive
, array
, enum
, or annotation
.annotation
- is the type of the requested annotation.
null
if neither the
annotatedInterface
nor one of its
super-interfaces
are
annotated
with the given
annotation
.public <A extends Annotation> A getTypeAnnotation(Class<?> annotatedType, Class<A> annotation)
annotation
of
the type given by annotation
in the declaration of the given
annotatedType
.AnnotationUtil.getClassAnnotation(Class, Class)
this method will also
scan implemented interfaces for the given annotation
.annotation
is a
runtime
annotation.
getTypeAnnotation
in interface AnnotationUtil
A
- is the type of the requested annotation.annotatedType
- is the class or interface potentially annotated with
the given annotation
. This should NOT be an
primitive
, array
, enum
, or annotation
.annotation
- is the type of the requested annotation.
null
if neither the
annotatedType
nor one of its
super-classes
, or any implemented
interfaces
(no matter if implemented
directly or indirectly) are annotated
with the given annotation
.public <A extends Annotation> A getMethodAnnotation(Method annotatedMethod, Class<A> annotation)
annotation
of
the type given by annotation
in the
hierarchy
of the given
method
.annotation
is a
runtime
annotation.
getMethodAnnotation
in interface AnnotationUtil
A
- is the type of the requested annotation.annotatedMethod
- is the method potentially annotated with the given
annotation
.annotation
- is the type of the requested annotation.
null
if neither the
annotatedMethod
nor one of its
parent methods
are
annotated
with the given
annotation
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |