All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.leeonky.util.MethodProperty Maven / Gradle / Ivy

The newest version!
package com.github.leeonky.util;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

abstract class MethodProperty extends AbstractPropertyAccessor {
    final Method method;

    MethodProperty(BeanClass beanClass, Method method) {
        super(beanClass);
        this.method = method;
    }

    @Override
    public  A getAnnotation(Class annotationClass) {
        A annotation = AnnotationGetter.getInstance().getAnnotation(method, annotationClass);
        if (annotation != null)
            return annotation;
        try {
            return AnnotationGetter.getInstance().getAnnotation(
                    method.getDeclaringClass().getDeclaredField(getName()), annotationClass);
        } catch (NoSuchFieldException e) {
            return null;
        }
    }

    @Override
    public boolean isBeanProperty() {
        return !Modifier.isStatic(method.getModifiers());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy