mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-04 17:59:35 +01:00
Implement AnnotatedElement contract in MethodInfo
This commit is contained in:
parent
cb5633aba8
commit
0b4ce155ac
@ -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();
|
||||||
|
Loading…
Reference in New Issue
Block a user