解析Getter
//package com.nowjava; import java.lang.reflect.Method;/** 来 自 NowJava.com - 时代Java**/ public class Main { private static final String GET_PREFIX = "get"; private static final String IS_PREFIX = "is"; public static Method parseGetter(Object bean, String propertyName, Class<?> propertyClass) throws SecurityException, NoSuchMethodException { return bean.getClass().getMethod( getGetMethodName(propertyName, propertyClass)); } public static String getGetMethodName(String propertyName, Class<?> propertyClass) { if (propertyClass == boolean.class) {/** from n o w j a v a . c o m**/ return IS_PREFIX + capitalizeMethodName(propertyName); } else if (propertyClass == Boolean.class) { return IS_PREFIX + capitalizeMethodName(propertyName); } else { return GET_PREFIX + capitalizeMethodName(propertyName); } } private static