public final class AnnotationFactory extends Object implements InvocationHandler, Serializable
java.lang.reflect.AnnotatedElement
and java.lang.annotation.Annotation
.
Namely, annotation instances are immutable and serializable; they provide
conforming access to annotation member values and required implementations of
methods declared in Annotation interface.android.lang.annotation.AnnotationMember
,
Annotation
,
Serialized FormModifier and Type | Method and Description |
---|---|
static Annotation |
createAnnotation(Class<? extends Annotation> annotationType,
AnnotationMember[] elements)
Provides a new annotation instance.
|
boolean |
equals(Object obj)
Returns true if the specified object represents the same annotation instance.
|
static AnnotationMember[] |
getElementsDescription(Class<? extends Annotation> annotationType)
Reflects specified annotation type and returns an array
of member element definitions with default values.
|
int |
hashCode()
Returns a hash code composed as a sum of hash codes of member elements,
including elements with default values.
|
Object |
invoke(Object proxy,
Method method,
Object[] args)
Processes a method invocation request to this annotation instance.
|
String |
toString()
Provides detailed description of this annotation instance,
including all member name-values pairs.
|
public static AnnotationMember[] getElementsDescription(Class<? extends Annotation> annotationType)
public static Annotation createAnnotation(Class<? extends Annotation> annotationType, AnnotationMember[] elements)
annotationType
- the annotation type definitionelements
- name-value pairs representing elements of the annotationpublic boolean equals(Object obj)
public int hashCode()
public String toString()
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
java.lang.annotation.Annotation
interface, and member-defining methods of the implemented annotation type.invoke
in interface InvocationHandler
proxy
- the proxy instance on which the method was invokedmethod
- the method invoked on the proxy instanceargs
- an array of objects containing the parameters passed to the
method, or null
if no arguments are expected.
Primitive types are boxed.IllegalArgumentException
- If the specified method is none of the aboveThrowable
- the exception to throw from the invoked method on the proxy.
The exception must match one of the declared exception types
of the invoked method or any unchecked exception type. If not
then an UndeclaredThrowableException
is thrown