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

de.escalon.hypermedia.AnnotationUtils Maven / Gradle / Ivy

The newest version!
package de.escalon.hypermedia;

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

/**
 * Created by Dietrich on 05.04.2015.
 */
public class AnnotationUtils {

    private AnnotationUtils() {
    }

    public static  T findAnnotation(AnnotatedElement annotated, Class annotationClass) {
        T ret;
        if (annotated == null) {
            ret = null;
        } else {
            ret = annotated.getAnnotation(annotationClass);
        }
        return ret;
    }

    public static Method getAnnotatedMethod(Class clazz, Class annotation) {
        Method[] methods = clazz.getMethods();
        Method ret = null;
        for (Method method : methods) {
            if (method.getAnnotation(annotation) != null) {
                ret = method;
                break;
            }
        }
        return ret;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy