Here you can find the source of getMethodsWith(Class> c, Class>... parameters)
Parameter | Description |
---|---|
c | The class |
parameters | Which parameters should be checked |
public static List<Method> getMethodsWith(Class<?> c, Class<?>... parameters)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { /**//from w w w. ja v a 2 s .co m * Returns a method from a class with the given parameters * * @param c The class * @param parameters Which parameters should be checked * @return The found method */ public static List<Method> getMethodsWith(Class<?> c, Class<?>... parameters) { List<Class<?>> params = Arrays.asList(parameters); List<Method> methods = new ArrayList<>(); for (Method m : c.getMethods()) { for (Class<?> p : m.getParameterTypes()) { if (params.contains(p)) methods.add(m); } } return methods; } }