org.fluentlenium.utils.AnnotationUtil Maven / Gradle / Ivy
package org.fluentlenium.utils;
import org.fluentlenium.adapter.exception.AnnotationNotFoundException;
import org.fluentlenium.adapter.exception.MethodNotFoundException;
import java.lang.annotation.Annotation;
public final class AnnotationUtil {
private AnnotationUtil() {
}
public static T getClassAnnotationForClass(
Class annotation, Class> classFromThread) {
T definedAnnotation = classFromThread.getAnnotation(annotation);
if (definedAnnotation == null) {
throw new AnnotationNotFoundException();
}
return definedAnnotation;
}
public static T getMethodAnnotationForMethod(
Class annotation, Class> classFromThread, String methodNameFromThread) {
T definedAnnotation;
try {
definedAnnotation = classFromThread.getDeclaredMethod(methodNameFromThread)
.getAnnotation(annotation);
} catch (NoSuchMethodException e) {
throw new MethodNotFoundException(e);
}
if (definedAnnotation == null) {
throw new AnnotationNotFoundException();
}
return definedAnnotation;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy