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

}

拿去,不用谢

相关推荐
杨杨杨大侠3 小时前
都能接模型、RAG 和 MCP,Java Agent 框架到底差在哪?
java
破茧蝴蝶3 小时前
Python分布式爬虫完整教程
开发语言·python
狗凯之家源码网3 小时前
全新 PHP 轻量客服聊天室源码深度评测
开发语言·php·聊天室系统
远离UE44 小时前
UE5 Substrate Thin Film 源码拆析
开发语言·javascript·ue5
keyipatience4 小时前
JavaScript学习(1)书写位置,变量、数据类型、运算符
开发语言·前端·javascript·css·学习
Thinker QAQ4 小时前
并发编程(九):BlockingQueue 与 Channel——语言层的原子性、可见性与有序性
java·python·go·并发编程·channel·blockingqueue·message passing
栈帧之外5 小时前
【C++】STL之set
开发语言·c++
霸道流氓气质5 小时前
RAG 可观测性与生产监控实战:四层遥测模型、五大仪表盘与 OpenTelemetry 全链路追踪的 Java 生产级实现
java·人工智能·python
AOI小白新手上路5 小时前
autodl常用的tar 打包下载(数据集)命令手册:逐段拆解与套用模板
java·大数据·数据库
catchadmin5 小时前
免费可商用 PHP 管理后台 CatchAdmin V5.4.1 发布,新增 MCP 支持
开发语言·php