Here you can find the source of getMethodsByStartsWithName(String name, Object o)
Parameter | Description |
---|---|
name | a parameter |
public static Collection<Method> getMethodsByStartsWithName(String name, Object o) throws NoSuchMethodException, IllegalAccessException
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; public class Main { /**// w w w . ja va2 s . c o m * this will get all mehods whose names start with the expressed string * @param name * @return */ public static Collection<Method> getMethodsByStartsWithName(String name, Object o) throws NoSuchMethodException, IllegalAccessException { Collection<Method> methods = new ArrayList<Method>(); Class c = o.getClass(); java.lang.reflect.Method[] theMethods = c.getMethods(); for (int i = 0; i < theMethods.length; i++) { String methodString = theMethods[i].getName(); //is this a method we want to use? if (methodString.startsWith(name)) { methods.add(theMethods[i]); Class[] parameterTypes = theMethods[i].getParameterTypes(); } } return methods; } }