
package io.jmnarloch.spring.boot.rxjava.metadata;

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

/**
 * The annotation inspector, capable for extracting the annotation from the given type.
 *
 * @param <A> the annotation type
 * @author Jakub Narloch
 */
public class AnnotationInspector<A extends Annotation> {

    private final Method method;

    private final Class<A> annotationType;

    public AnnotationInspector(Method method, Class<A> annotationType) {
        this.method = method;
        this.annotationType = annotationType;
    }

    public boolean isAnnotationPresent() {
        return method.isAnnotationPresent(annotationType);
    }

    public A getAnnotation() {
        return method.getAnnotation(annotationType);
    }

    public Method getMethod() {
        return method;
    }
}
