Simplify SynthesizedMergedAnnotationInvocationHandler.invoke()
This commit is contained in:
parent
fe7355d5b0
commit
5bcbcb3049
|
@ -73,29 +73,23 @@ final class SynthesizedMergedAnnotationInvocationHandler<A extends Annotation> i
|
|||
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) {
|
||||
if (ReflectionUtils.isEqualsMethod(method)) {
|
||||
return annotationEquals(args[0]);
|
||||
}
|
||||
if (ReflectionUtils.isHashCodeMethod(method)) {
|
||||
return annotationHashCode();
|
||||
}
|
||||
if (ReflectionUtils.isToStringMethod(method)) {
|
||||
return annotationToString();
|
||||
}
|
||||
if (isAnnotationTypeMethod(method)) {
|
||||
return this.type;
|
||||
}
|
||||
if (this.attributes.indexOf(method.getName()) != -1) {
|
||||
return getAttributeValue(method);
|
||||
}
|
||||
if (method.getParameterCount() == 0) {
|
||||
switch (method.getName()) {
|
||||
case "annotationType": return this.type;
|
||||
case "hashCode": return annotationHashCode();
|
||||
case "toString": return annotationToString();
|
||||
}
|
||||
}
|
||||
if (ReflectionUtils.isEqualsMethod(method)) {
|
||||
return annotationEquals(args[0]);
|
||||
}
|
||||
throw new AnnotationConfigurationException(String.format(
|
||||
"Method [%s] is unsupported for synthesized annotation type [%s]", method, this.type));
|
||||
}
|
||||
|
||||
private boolean isAnnotationTypeMethod(Method method) {
|
||||
return (method.getName().equals("annotationType") && method.getParameterCount() == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link Annotation#equals(Object)} for a definition of the required algorithm.
|
||||
* @param other the other object to compare against
|
||||
|
|
Loading…
Reference in New Issue