Here you can find the source of getMethodsWithAnnotation(Class extends Annotation> annotation, Class clazz)
Parameter | Description |
---|---|
annotation | The annotation to search for |
clazz | The class to search in |
public static List<Method> getMethodsWithAnnotation(Class<? extends Annotation> annotation, Class clazz)
//package com.java2s; //License from project: Open Source License import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; public class Main { /**// www. j a v a 2 s .com * Gets a list of methods with the given annotation * @param annotation The annotation to search for * @param clazz The class to search in * @return The methods with the annotation */ public static List<Method> getMethodsWithAnnotation(Class<? extends Annotation> annotation, Class clazz) { Method[] methods = clazz.getMethods(); List<Method> annotated = new ArrayList<Method>(); for (Method m : methods) if (m.isAnnotationPresent(annotation)) annotated.add(m); return annotated; } }