Java tutorial
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; public class Main { private static boolean isCandidate(Method m, String methodName, List<Object> availableParams, List<Object> paramsContainer) { if (m.getName().equals(methodName) == false) { return false; } Class<?>[] paramTypes = m.getParameterTypes(); if (paramTypes.length == 0) { return true; } paramsContainer.addAll(createParamsArray(m, availableParams)); /* * we found match for every type */ return paramsContainer.size() == paramTypes.length; } private static List<Object> createParamsArray(Method m, List<Object> availableParams) { List<Object> params = new ArrayList<Object>(); Class<?>[] paramTypes = m.getParameterTypes(); for (Class<?> type : paramTypes) { for (Object param : availableParams) { if (param != null && type.isAssignableFrom(param.getClass())) { params.add(param); } } } return params; } }