java代码快速生成get和set方法

java 复制代码
import com.framework.emt.system.domain.exception.ExceptionCategory;

import java.lang.reflect.Method;

public class GetAllSetMethods {

    public static void main(String[] args) {
        ExceptionCategory exceptionCategory = new ExceptionCategory();
        getAllSetMethods(exceptionCategory);
    }

    public static void getAllSetMethods(Object object) {
        Class<?> clazz = object.getClass();
        Method[] methods = clazz.getMethods();

        for (Method method : methods) {
            if (isSetMethod(method)) {
                System.out.println(method.getName() + "();");
            }
        }
    }

    public static boolean isSetMethod(Method method) {
        String methodName = method.getName();
        return methodName.startsWith("set") && methodName.length() > 3;
    }

}

拿去,不用谢

相关推荐
YuK.W31 分钟前
Leetcode100: 70.爬楼梯、118.杨辉三角、198.打家劫舍
java·算法·leetcode
这不小天嘛1 小时前
JAVA八股——redis篇
java·开发语言·redis
逝水无殇2 小时前
C# 字符串(String)详解
开发语言·后端·c#
精明的身影2 小时前
C++自学之路1:Hello world
开发语言·c++
leo__5203 小时前
基于导航数据的扩展卡尔曼滤波(EKF)MATLAB 实现
开发语言·matlab
gugucoding3 小时前
25. 【C语言】二进制文件与随机读写
c语言·开发语言
北极星日淘3 小时前
中古货品品相评级算法实战|Java权重计分实现标准化五级品相体系
开发语言·python
聚美智数3 小时前
黄历查询-运势查询-国际法定节假日查询-API接口介绍
android·java·数据库
小巧的砖头3 小时前
C#会重蹈覆辙吗?系列之2:反射及元数据的性能问题
开发语言·前端·c#
凯瑟琳.奥古斯特3 小时前
力扣1009补码解法C++实现
开发语言·c++·算法·leetcode·职场和发展