Annotation that pretends it is a
"real" source code annotation. It's also an InvocationHandler.
When you create an AnnotationProxy, you must initialize it
with an AnnotationDescriptor.
The adapter checks that the provided elements are the same elements defined
in the annotation interface. However, it does not check that their
values are the right type. If you omit an element, the adapter will use the
default value for that element from the annotation interface, if it exists.
If no default exists, it will throw an exception.
Warning
this class does not implement hashCode() and
equals() - it just uses the ones it inherits from Object.
This means that an AnnotationProxy does not follow the
recommendations of the Annotation javadoc about these two
methods. That's why you should never mix AnnotationProxies
with "real" annotations. For example, don't put them into the same
Collection.
java.lang.annotation.Annotation
| Modifier and Type | Field and Description |
|---|---|
| private final Class | |
| private final Map |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Class | annotationType()
Implements java. |
| private Map | |
| private SortedSet | |
| public Object | invoke(Object
the proxy instance that the method was invoked on proxy, Method the method, Object[] Method instance corresponding to
the interface method invoked on the proxy instance. The declaring
class of the Method object will be the interface that
the method was declared in, which may be a superinterface of the
proxy interface that the proxy class inherits the method through.an array of objects containing the values of the
arguments passed in the method invocation on the proxy instance,
or args)null if interface method takes no arguments.
Arguments of primitive types are wrapped in instances of the
appropriate primitive wrapper class, such as
java.lang.Integer or java.lang.Boolean.Implements java. |
| public String | toString()
Overrides java. Implements java. |
| annotationType | back to summary |
|---|---|
| private final Class<? extends Annotation> annotationType | |
| values | back to summary |
|---|---|
| private final Map<Method, Object> values | |
| AnnotationProxy | back to summary |
|---|---|
| public AnnotationProxy(AnnotationDescriptor descriptor) | |
| annotationType | back to summary |
|---|---|
| public Class Implements java. Doc from java. Returns the annotation interface of this annotation.
| |
| getAnnotationValues | back to summary |
|---|---|
| private Map | |
| getRegisteredMethodsInAlphabeticalOrder | back to summary |
|---|---|
| private SortedSet | |
| invoke | back to summary |
|---|---|
| public Object invoke(Object proxy, Method method, Object[] args) throws Throwable Implements java. Doc from java. Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Implements java. Doc from java. Returns a string representation of this annotation. The details of the representation are implementation-dependent, but the following may be regarded as typical: @com.example.Name(first="Duke", middle="of", last="Java")
| |