All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.jfunc.json.util.BeanInfoUtil Maven / Gradle / Ivy

The newest version!
package top.jfunc.json.util;

import java.lang.reflect.Method;

public class BeanInfoUtil {
    /**
     * 根据field 找到相应的getter,可能返回null
     */
    public static Method getGetter(Class clazz , String fieldName){
        String prop = fieldName.substring(0,1).toUpperCase() + fieldName.substring(1);
        try {
            return clazz.getMethod("get" + prop);
        } catch (NoSuchMethodException e) {
            try {
                //boolean 类型的
                return clazz.getMethod("is" + prop);
            } catch (NoSuchMethodException e1) {
                return null;
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy