Here you can find the source of invokeTargetMethods(Object obj, T data, List
static <T> void invokeTargetMethods(Object obj, T data, List<Method> methods) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
//package com.java2s; //License from project: Open Source License import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Parameter; import java.util.List; public class Main { static <T> void invokeTargetMethods(Object obj, T data, List<Method> methods) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { for (Method target : methods) { for (Parameter paramType : target.getParameters()) { Class<?> parClass = paramType.getType(); if (parClass.isAssignableFrom(data.getClass())) { target.invoke(obj, data); }//from w w w.ja v a 2 s . c om } } } }