Here you can find the source of getGettersAndSetters(Object obj)
public static Method[] getGettersAndSetters(Object obj)
//package com.java2s; /*//from w w w . j av a 2 s .c o m * $Id$ * * Copyright 2006 University of Dundee. All rights reserved. * Use is subject to license terms supplied in LICENSE.txt */ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; public class Main { public static Method[] getGettersAndSetters(Object obj) { Method[] methods, superMethods = null; methods = obj.getClass().getDeclaredMethods(); Package pkg = obj.getClass().getPackage(); if (null != pkg && pkg.toString().indexOf("ome.model2") > -1) {// FIXME // not // valid superMethods = obj.getClass().getSuperclass().getDeclaredMethods(); } List goodMethods = checkGettersAndSetters(methods); goodMethods.addAll(checkGettersAndSetters(superMethods)); return (Method[]) goodMethods.toArray(new Method[goodMethods.size()]); } static List checkGettersAndSetters(Method[] methods) { List goodMethods = new ArrayList(); if (null == methods) { return goodMethods; } for (int i = 0; i < methods.length; i++) { boolean ok = true; Method method = methods[i]; int mod = method.getModifiers(); if (!Modifier.isPublic(mod) || Modifier.isStatic(mod)) { ok = false; } if (method.getName().startsWith("get")) { if (0 != method.getParameterTypes().length) { ok = false; } } else if (method.getName().startsWith("set")) { // No constaints yet on setters. } else { ok = false; } if (ok) { goodMethods.add(method); } } return goodMethods; } }