Top Description Fields Constructors Methods
org.springframework.core.annotation

pack-priv final Class SynthesizedMergedAnnotationInvocationHandler<A extends Annotation>

extends Object
implements InvocationHandler
Class Inheritance
All Implemented Interfaces
java.lang.reflect.InvocationHandler
Type Parameters
<A>
the annotation type
Imports
java.lang.annotation.Annotation, java.lang.reflect.AnnotatedElement, .Array, .InvocationHandler, .Method, .Proxy, java.util.Map, .NoSuchElementException, java.util.concurrent.ConcurrentHashMap, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils, .ObjectUtils, .ReflectionUtils

InvocationHandler for an Annotation that Spring has synthesized (i.e. wrapped in a dynamic proxy) with additional functionality such as attribute alias handling.
Authors
Sam Brannen, Phillip Webb
Since
5.2
See Also
Annotation, AnnotationUtils#synthesizeAnnotation(Annotation, AnnotatedElement)

Field Summary

Modifier and TypeField and Description
private final MergedAnnotation<?>
private final AttributeMethods
private volatile Integer
private volatile String
private final Class<A>
private final Map<String, Object>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private boolean
annotationEquals(Object
the other object to compare against
other
)

See Annotation#equals(Object) for a definition of the required algorithm.

private int
annotationHashCode()

See Annotation#hashCode() for a definition of the required algorithm.

private String
private Object
cloneArray(Object
the array to clone
array
)

Clone the provided array, ensuring that the original component type is retained.

private Integer
pack-priv static <A extends Annotation> A
createProxy(MergedAnnotation<A> annotation, Class<A> type)

private Object
private static String
getName(Class<?> clazz)

public Object
invoke(Object
the proxy instance that the method was invoked on
proxy
,
Method
the 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.
method
,
Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or 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.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result.

private String

Returns:

the formatted string representation
toString
(Object
the attribute value to format
value
)

This method currently does not address the following issues which we may choose to address at a later point in time.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationback to summary
private final MergedAnnotation<?> annotation
attributesback to summary
private final AttributeMethods attributes
hashCodeback to summary
private volatile Integer hashCode
Annotations
@Nullable
stringback to summary
private volatile String string
Annotations
@Nullable
typeback to summary
private final Class<A> type
valueCacheback to summary
private final Map<String, Object> valueCache

Constructor Detail

SynthesizedMergedAnnotationInvocationHandlerback to summary
private SynthesizedMergedAnnotationInvocationHandler(MergedAnnotation<A> annotation, Class<A> type)

Method Detail

annotationEqualsback to summary
private boolean annotationEquals(Object other)

See Annotation#equals(Object) for a definition of the required algorithm.

Parameters
other:Object

the other object to compare against

annotationHashCodeback to summary
private int annotationHashCode()

See Annotation#hashCode() for a definition of the required algorithm.

annotationToStringback to summary
private String annotationToString()
cloneArrayback to summary
private Object cloneArray(Object array)

Clone the provided array, ensuring that the original component type is retained.

Parameters
array:Object

the array to clone

computeHashCodeback to summary
private Integer computeHashCode()
createProxyback to summary
pack-priv static <A extends Annotation> A createProxy(MergedAnnotation<A> annotation, Class<A> type)
Annotations
@SuppressWarnings:unchecked
getAttributeValueback to summary
private Object getAttributeValue(Method method)
getNameback to summary
private static String getName(Class<?> clazz)
invokeback to summary
public Object invoke(Object proxy, Method method, Object[] args)

Implements java.lang.reflect.InvocationHandler.invoke.

Doc from java.lang.reflect.InvocationHandler.invoke.

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.

Parameters
proxy:Object

the proxy instance that the method was invoked on

method:Method

the 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.

args:Object[]

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or 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.

Returns:Object

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Annotations
@Override
toStringback to summary
private String toString(Object value)

This method currently does not address the following issues which we may choose to address at a later point in time.

  • non-ASCII, non-visible, and non-printable characters within a character or String literal are not escaped.
  • formatting for float and double values does not take into account whether a value is not a number (NaN) or infinite.
Parameters
value:Object

the attribute value to format

Returns:String

the formatted string representation