From 0b4ce155ac7e1ee015ea048df6d5231bc09d0954 Mon Sep 17 00:00:00 2001 From: Jonas Konrad Date: Sat, 21 Mar 2015 14:19:59 +0100 Subject: [PATCH] Implement AnnotatedElement contract in MethodInfo --- .../protocol/reflect/MethodInfo.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/MethodInfo.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/MethodInfo.java index a2a9585f..8b6598cd 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/MethodInfo.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/MethodInfo.java @@ -1,5 +1,6 @@ package com.comphenix.protocol.reflect; +import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.GenericDeclaration; import java.lang.reflect.Member; @@ -24,6 +25,18 @@ public abstract class MethodInfo implements GenericDeclaration, Member { */ public static MethodInfo fromMethod(final Method method) { return new MethodInfo() { + // @Override + public T getAnnotation(Class annotationClass) { + return method.getAnnotation(annotationClass); + } + // @Override + public Annotation[] getAnnotations() { + return method.getAnnotations(); + } + // @Override + public Annotation[] getDeclaredAnnotations() { + return method.getDeclaredAnnotations(); + } @Override public String getName() { return method.getName(); @@ -104,6 +117,18 @@ public abstract class MethodInfo implements GenericDeclaration, Member { */ public static MethodInfo fromConstructor(final Constructor constructor) { return new MethodInfo() { + // @Override + public T getAnnotation(Class annotationClass) { + return constructor.getAnnotation(annotationClass); + } + // @Override + public Annotation[] getAnnotations() { + return constructor.getAnnotations(); + } + // @Override + public Annotation[] getDeclaredAnnotations() { + return constructor.getDeclaredAnnotations(); + } @Override public String getName() { return constructor.getName();