Archiviert
13
0

Implement AnnotatedElement contract in MethodInfo

Dieser Commit ist enthalten in:
Jonas Konrad 2015-03-21 14:19:59 +01:00
Ursprung cb5633aba8
Commit 0b4ce155ac

Datei anzeigen

@ -1,5 +1,6 @@
package com.comphenix.protocol.reflect; package com.comphenix.protocol.reflect;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.GenericDeclaration; import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.Member; import java.lang.reflect.Member;
@ -24,6 +25,18 @@ public abstract class MethodInfo implements GenericDeclaration, Member {
*/ */
public static MethodInfo fromMethod(final Method method) { public static MethodInfo fromMethod(final Method method) {
return new MethodInfo() { return new MethodInfo() {
// @Override
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
return method.getAnnotation(annotationClass);
}
// @Override
public Annotation[] getAnnotations() {
return method.getAnnotations();
}
// @Override
public Annotation[] getDeclaredAnnotations() {
return method.getDeclaredAnnotations();
}
@Override @Override
public String getName() { public String getName() {
return method.getName(); return method.getName();
@ -104,6 +117,18 @@ public abstract class MethodInfo implements GenericDeclaration, Member {
*/ */
public static MethodInfo fromConstructor(final Constructor<?> constructor) { public static MethodInfo fromConstructor(final Constructor<?> constructor) {
return new MethodInfo() { return new MethodInfo() {
// @Override
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
return constructor.getAnnotation(annotationClass);
}
// @Override
public Annotation[] getAnnotations() {
return constructor.getAnnotations();
}
// @Override
public Annotation[] getDeclaredAnnotations() {
return constructor.getDeclaredAnnotations();
}
@Override @Override
public String getName() { public String getName() {
return constructor.getName(); return constructor.getName();