Here you can find the source of getMethods(Object obj, int cmpModifier, String prefix)
private static Method[] getMethods(Object obj, int cmpModifier, String prefix)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { private static Method[] getMethods(Object obj, int cmpModifier, String prefix) {/* w w w. j av a 2s . c o m*/ Method[] retMethod = null; Class<?> objClass = obj.getClass(); Method[] methods = objClass.getDeclaredMethods(); if (methods != null && !(methods.length < 1)) { int j = 0; for (int i = 0; i < methods.length; i++) { int modifier = methods[i].getModifiers(); if (prefix != null && !prefix.equals("")) { if (modifier == cmpModifier && methods[i].getName().startsWith(prefix)) j++; } else if (modifier == cmpModifier) j++; } retMethod = new Method[j]; j = 0; for (int i = 0; i < methods.length; i++) { int modifier = methods[i].getModifiers(); if (prefix != null && !prefix.equals("")) { if (modifier == cmpModifier && methods[i].getName().startsWith(prefix)) { retMethod[j] = methods[i]; j++; } } else if (modifier == cmpModifier) retMethod[j] = methods[i]; } return retMethod; } else return null; } }