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;
    }

}

拿去,不用谢

相关推荐
与遨游于天地几秒前
NIO的三个组件解决三个问题
java·后端·nio
czlczl2002092527 分钟前
Guava Cache 原理与实战
java·后端·spring
徐先生 @_@|||27 分钟前
Palantir Foundry 五层架构模型详解
开发语言·python·深度学习·算法·机器学习·架构
yangminlei29 分钟前
Spring 事务探秘:核心机制与应用场景解析
java·spring boot
tang777891 小时前
爬虫如何绕过绕过“5秒盾”Cloudflare:从浏览器指纹模拟到Rust求解之不完全指南
开发语言·爬虫·rust·cloudflare
Yuer20251 小时前
什么是 Rust 语境下的“量化算子”——一个工程对象的最小定义
开发语言·后端·rust·edca os·可控ai
hqwest1 小时前
码上通QT实战26--系统设置01-系统设置布局
开发语言·qt·qss·qt基础控件·qt布局控件·qt表格控件
薛定谔的猫19821 小时前
llama-index Embedding 落地到 RAG 系统
开发语言·人工智能·python·llama-index
记得开心一点嘛1 小时前
Redis封装类
java·redis
lkbhua莱克瓦242 小时前
进阶-存储过程3-存储函数
java·数据库·sql·mysql·数据库优化·视图