mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-08-19 03:52:51 +02:00
Merge pull request #61 from yawkat/8-patch-0
Implement AnnotatedElement contract in MethodInfo
This commit is contained in:
commit
923f4f4c4a
|
@ -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