学习5 获取字段名称

来源:互联网 发布:高大上ppt制作技巧知乎 编辑:程序博客网 时间:2024/05/22 06:29
 
    /**     * 获取字段名称     * @param method     * @return     */    private static String getFieldByMethod(Method method)    {        String methodName = method.getName();        String fieldName = null;        if (!"getClass".equals(methodName))        {            if (methodName.startsWith("get"))            {                fieldName = methodName.substring(3);            }            else if (methodName.startsWith("is"))            {                fieldName = methodName.substring(2);            }        }        return fieldName;    }

原创粉丝点击