Here you can find the source of getMethods(final Class> clazz, final String methodName)
Parameter | Description |
---|---|
clazz | a parameter |
methodName | a parameter |
public static List<Method> getMethods(final Class<?> clazz, final String methodName)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; public class Main { /** Find at the object all method where its name be equals to the method name as parameter. * It returns a list with all methods with the same name, but with differents parameters. *//from w ww .j av a 2s . c om * @param obj * @param methodName * @return a list's method with method name as parameter. */ public static List<Method> getMethods(final Object obj, final String methodName) { return getMethods(obj.getClass(), methodName); } /** Find at the class all methods where its name be equals to the method name as parameter. * It returns a list with all methods with the same name, but with differents parameteres. * * @param clazz * @param methodName * @return a list's method with method name as parameter. */ public static List<Method> getMethods(final Class<?> clazz, final String methodName) { Method[] arrayMethod = clazz.getMethods(); List<Method> resultMethodList = new ArrayList<Method>(); for (Method currentMethod : arrayMethod) { if (currentMethod.getName().equalsIgnoreCase(methodName)) { resultMethodList.add(currentMethod); } } return resultMethodList; } }