public class AnnotationUtilImpl extends AbstractLoggableComponent implements AnnotationUtil
annotations
.getInstance()
Modifier and Type | Field and Description |
---|---|
private static AnnotationUtilImpl |
instance |
private ReflectionUtil |
reflectionUtil |
NO_TARGET
Constructor and Description |
---|
AnnotationUtilImpl()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doInitialized()
This method is invoked at the end of the actual
initialization . |
<A extends Annotation> |
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 <A extends Annotation> |
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
. |
<A extends Annotation> |
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. |
<A extends Annotation> |
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 . |
<A extends Annotation> |
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 . |
<A extends Annotation> |
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) |
createLogger, doInitialize, getLogger
getInitializationState, initialize
private static AnnotationUtilImpl instance
private ReflectionUtil reflectionUtil
protected void doInitialized()
AbstractComponent
initialization
. It is called when
AbstractComponent.initialize()
is invoked for the first time after AbstractComponent.doInitialize()
is completed and
initialization-state
has changed to initialized
. super.
AbstractComponent.doInitialized()
.doInitialized
in class AbstractComponent
public static AnnotationUtilImpl getInstance()
AnnotationUtilImpl
. Cdi.GET_INSTANCE
before using.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)
AnnotationUtil
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)
AnnotationUtil
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
AnnotationUtil
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)
AnnotationUtil
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)
AnnotationUtil
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
.Copyright © 2001–2016 mmm-Team. All rights reserved.