public class AnnotationInstanceProvider extends Object implements 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 Annotation> |
annotationType() |
boolean |
equals(Object o) |
int |
hashCode() |
Object |
invoke(Object proxy,
Method method,
Object[] args) |
static <T extends Annotation> |
of(Class<T> annotationClass)
Creates an annotation instance for the given annotation class
|
static <T extends 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 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 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 Annotation> annotationType()
annotationType
in interface Annotation
public String toString()
toString
in interface Annotation
toString
in class Object
public boolean equals(Object o)
equals
in interface Annotation
equals
in class Object
public int hashCode()
hashCode
in interface Annotation
hashCode
in class Object
Copyright © 2020 The Apache Software Foundation. All rights reserved.