public class AnnotationInstanceProvider extends Object implements java.lang.annotation.Annotation, InvocationHandler, Serializable
A small helper class to create an Annotation instance of the given annotation class
via Proxy
. The annotation literal gets filled with the default values.
This class can be used to dynamically create Annotations which can be usd in AnnotatedTyp.
This is e.g. the case if you configure an annotation via properties or XML file. In those cases you
cannot use AnnotationLiteral
because the type is not known at compile time.
usage:
String annotationClassName = ...; Class extends annotation> annotationClass = (Class extends Annotation>) ClassUtils.getClassLoader(null).loadClass(annotationClassName); Annotation a = AnnotationInstanceProvider.of(annotationClass)
Modifier and Type | Method and Description |
---|---|
Class<? extends java.lang.annotation.Annotation> |
annotationType() |
boolean |
equals(Object o) |
int |
hashCode() |
Object |
invoke(Object proxy,
Method method,
Object[] args) |
static <T extends java.lang.annotation.Annotation> |
of(Class<T> annotationClass)
Creates an annotation instance for the given annotation class
|
static <T extends java.lang.annotation.Annotation> |
of(Class<T> annotationClass,
Map<String,?> values)
Creates an annotation instance for the given annotation class
|
String |
toString()
Copied from Apache OWB (javax.enterprise.util.AnnotationLiteral#toString())
with minor changes.
|
public static <T extends java.lang.annotation.Annotation> T of(Class<T> annotationClass, Map<String,?> values)
T
- current typeannotationClass
- type of the target annotationvalues
- A non-null map of the member values, keys being the name of the memberspublic static <T extends java.lang.annotation.Annotation> T of(Class<T> annotationClass)
T
- current typeannotationClass
- type of the target annotationpublic Object invoke(Object proxy, Method method, Object[] args) throws Exception
invoke
in interface InvocationHandler
Exception
public Class<? extends java.lang.annotation.Annotation> annotationType()
annotationType
in interface java.lang.annotation.Annotation
public String toString()
toString
in interface java.lang.annotation.Annotation
toString
in class Object
public boolean equals(Object o)
equals
in interface java.lang.annotation.Annotation
equals
in class Object
public int hashCode()
hashCode
in interface java.lang.annotation.Annotation
hashCode
in class Object
Copyright © 2015 The Apache Software Foundation. All rights reserved.